mediumReact Native#147

FlatList windowing math

Prompt

The math behind getItemLayout and virtualization, for fixed-height rows:

  1. makeItemLayout(rowHeight) → returns (data, index) => ({ length, offset, index })
  2. visibleRange(scrollY, viewportHeight, rowHeight, itemCount){ first, last } — the inclusive indexes of rows intersecting the viewport, clamped to [0, itemCount - 1]

Hints

Solution

Your Code

15 min

Tests

Click Run to test your code