FixedSizeList: Rendering Thousands of Items
Set up react-window's FixedSizeList for uniform-height rows and connect it to your data.
Installing react-window
You add react-window to a project with your package manager, for example installing the react-window package. It is small and has no heavy dependencies.
Once installed you import the list components you need, most commonly FixedSizeList for rows that all share the same height.
FixedSizeList Required Props
FixedSizeList needs several props to function: height and width define the scroll container, itemCount is how many items exist, and itemSize is the height of each row in pixels.
The children prop is a render function that draws a single row. With these, the component knows the geometry it needs to window correctly.
All lessons in this course
- The Large List Rendering Problem
- FixedSizeList: Rendering Thousands of Items
- VariableSizeList: Dynamic Row Heights
- Combining Virtualization with Data Fetching