Skip to content

Commit 9fc7162

Browse files
committed
fix: replace useLayoutEffect with useEffect for better performance
1 parent 918fc35 commit 9fc7162

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/components/Layout/DesktopCards.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLayoutEffect, useRef } from 'react'
1+
import { useEffect, useRef } from 'react'
22
import SortableList, { SortableItem } from 'react-easy-sort'
33
import { SUPPORTED_CARDS } from 'src/config/supportedCards'
44
import { CustomRssCard } from 'src/features/cards'
@@ -27,7 +27,7 @@ export const DesktopCards = ({
2727
}
2828
}
2929

30-
useLayoutEffect(() => {
30+
useEffect(() => {
3131
scrollHolderRef.current = document.querySelector('.Cards')
3232
}, [])
3333

@@ -36,10 +36,9 @@ export const DesktopCards = ({
3636
as="div"
3737
onSortEnd={onSortEnd}
3838
lockAxis="x"
39-
customHolderRef={scrollHolderRef}
4039
className="Cards HorizontalScroll"
4140
draggedItemClassName="draggedBlock">
42-
{cards
41+
{[...cards]
4342
.sort((a, b) => a.id - b.id)
4443
.map((card, index) => {
4544
const constantCard = AVAILABLE_CARDS.find((c) => c.value === card.name)
@@ -52,11 +51,7 @@ export const DesktopCards = ({
5251
return (
5352
<SortableItem key={card.name}>
5453
<div>
55-
<Component
56-
key={card.name}
57-
meta={constantCard}
58-
withAds={index === adsConfig.columnPosition}
59-
/>
54+
<Component meta={constantCard} withAds={index === adsConfig.columnPosition} />
6055
</div>
6156
</SortableItem>
6257
)

0 commit comments

Comments
 (0)