react-window-dynamic-list
Made with the awesome create-react-library
react-window
?
How is this different from This library comes to partly solve the case of rendering dynamically sized items with react-window. For more information about the issue please read this thread.
Before you overjoy please read the limitations of this approach down bellow
Demo
Install
npm install --save react-window-dynamic-list
Usage
Yep. its that simple
The api is the same as VariableSizeList with two small changes.
- Instead of
itemCount
you must passdata
(read more). - We handle
itemSize
andestimatedItemSize
for you😎
Implementations details
This solution is a really naive one, basically we do the following actions:
- Render the whole list, without windowing!
- measure all of the cells and cache the size.
- Remove the list.
- Render the virtualized list using the cached sizes.
⚠️ Requirements and Limitations ⚠️
Restrictions:
- It is feasible and possible (you have all of the data at hand) to load the data at the beginning for a brief time.
- Your data doesn't change its size
- You don't add new items to the list (filtering works
😏 ) - Currently this only supports vertical layout. (didn't have time to implement support for horizontal)
Data prop
The data props is expected to be an array of objects where each object contains an id
field.
License
MIT © gnir-work