Skip to content

Commit

Permalink
fix: move stable item style to outside scope
Browse files Browse the repository at this point in the history
This allows for item memoization as inline styles are changing referential equality between renders
  • Loading branch information
dominiczaq authored and petyosi committed Jul 18, 2023
1 parent cb156cc commit e613474
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/TableVirtuoso.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const DefaultFillerRow = ({ height }: { height: number }) => (
</tr>
)

const ITEM_STYLE = { overflowAnchor: 'none' } as const

const Items = /*#__PURE__*/ React.memo(function VirtuosoItems() {
const listState = useEmitterValue('listState')
const sizeRanges = usePublisher('sizeRanges')
Expand Down Expand Up @@ -146,7 +148,7 @@ const Items = /*#__PURE__*/ React.memo(function VirtuosoItems() {
'data-known-size': item.size,
'data-item-index': item.index,
item: item.data,
style: { overflowAnchor: 'none' },
style: ITEM_STYLE,
},
itemContent(item.index, item.data, context)
)
Expand Down

0 comments on commit e613474

Please sign in to comment.