Coding task · JavaScript and React course · Module 9: Modern React Hooks
Practice: List Virtualization
Virtualization renders only the rows visible in the window plus a few spare ones. The first visible row is Math.floor(scrollTop / ROW_HEIGHT), and every row stands at index * ROW_HEIGHT inside a container as tall as the full list.
Task
The catalog has 100,000 stars, but the list window fits only 10 rows of 40 px. Complete the virtualization: ___BLANK1___ is the state value that tells how many pixels the window has been scrolled, ___BLANK2___ is the array method that cuts out the stars from index start to end, and ___BLANK3___ is the index of the star in the full list (a field of the star object) that determines the top position of the row. Only a dozen or so rows should be in the DOM, and after scrolling the right stars should appear at the right height. Scroll the list in the preview and check the star numbers.