v5.0.0
5.0.0 (2024-10-08)
⚠ BREAKING CHANGES
- VirtualizedList: remove numberOfElementsVisibleOnScreen and numberOfElementsRendered props (#153)
Features
- add onLongSelect prop to Node (7dfae9a)
- VirtualizedList: remove numberOfElementsVisibleOnScreen and numberOfElementsRendered props (#153) (2268059)
Migration guide (should be quick)
Switching to the new version
In the latest version, the numberOfItemsVisibleOnScreen
and numberOfItemsRendered
props have been removed from the virtualized lists and grid API. The numberOfItemsVisibleOnScreen
is now calculated automatically based on the parent view size.
Both of these props have been replaced by a new optional prop called additionalItemsRendered
. This prop controls the number of items rendered just outside the visible screen (but not yet virtualized). It allows you to fine-tune the virtualization size without the need to manually calculate numberOfItemsVisibleOnScreen
, which could lead to incorrect values.
<SpatialNavigationVirtualizedList
data={data}
renderItem={renderItem}
itemSize={itemSize}
- numberOfItemsVisibleOnScreen={5}
- numberOfItemsRendered={8}
+ additionalItemsRendered={3} // optional
/>
How to Update to the New Version
To migrate to the new version, you'll need to remove the numberOfItemsVisibleOnScreen
and numberOfItemsRendered
props from all instances of SpatialNavigationVirtualizedList
and SpatialNavigationVirtualizedGrid
.
By default, you don't need to provide a value for additionalItemsRendered
. However, if you want to replicate the behavior of the previous version exactly, you can set additionalItemsRendered
to numberOfItemsRendered - numberOfItemsVisibleOnScreen
. This will ensure the same number of off-screen items are rendered.
Impact on Tests
Your tests may also break, as the number of visible items is now calculated based on the size of the parent view. This number will vary depending on the execution environment. For example, in Jest, where the window width is 750 px, the calculation will be based on that width.