File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -356,12 +356,18 @@ const ScriptMenuList = React.memo(
356356
357357 ListMenuItem . displayName = "ListMenuItem" ;
358358
359+ // 使用 useCallback 来缓存渲染函数,避免每次渲染都创建新的函数实例
360+ const renderListItem = useCallback (
361+ ( { item, index } : { item : ScriptMenu ; index : number } ) => (
362+ < ListMenuItem key = { `${ item . uuid } ` } item = { item } index = { index } />
363+ ) ,
364+ [ ]
365+ ) ;
366+
359367 return (
360368 < >
361369 { list . length === 0 && < Empty description = { t ( "no_data" ) } /> }
362- { list . map ( ( item , index ) => (
363- < ListMenuItem key = { `${ item . uuid } ` } item = { item } index = { index } />
364- ) ) }
370+ { list . map ( ( item , index ) => renderListItem ( { item, index } ) ) }
365371 </ >
366372 ) ;
367373 }
Original file line number Diff line number Diff line change @@ -202,10 +202,8 @@ function App() {
202202 // 检查位置,优化窗口过小,导致弹出菜单显示不全的问题
203203 setTimeout ( ( ) => {
204204 const dropdowns = document . getElementsByClassName ( "arco-dropdown" ) ;
205- console . log ( dropdowns ) ;
206205 if ( dropdowns . length > 0 ) {
207206 const dropdown = dropdowns [ 0 ] as HTMLElement ;
208- console . log ( dropdowns , dropdown . style . top ) ;
209207 // 如果top是负数修改为0
210208 if ( parseInt ( dropdown . style . top ) < 0 ) {
211209 dropdown . style . top = "0px" ;
You can’t perform that action at this time.
0 commit comments