Mid From PDF React React.js

How does virtualization work in React lists?

Virtualization is a technique where only the items that are visible in the viewport are

rendered, while the others are not rendered until they come into view. This significantly

reduces the number of DOM nodes and boosts performance when rendering large lists.

Popular libraries for virtualization in React include:

  • react-window
  • react-virtualized

Example with react-window:

import { FixedSizeList as List } from 'react-window';

function MyList({ items }) {

return (

<List

height={400}

itemCount={items.length}

itemSize={35}

width={300}

{({ index, style }) => (

<div style={style}>{items[index]}</div>

)}

</List>

);

}

Only the visible items will be rendered, and as the user scrolls, new items will be loaded

dynamically.

More from React.js Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details