Skip to content
Rung

11/12

No. 11Hard25 min

Performance: The Slow List

Mission

Fix a laggy list by finding unnecessary re-renders and removing them with React.memo, useMemo and useCallback.

Tasks

  1. 1

    Find the bottleneck: type in the input and watch the console. The whole list renders on every keystroke.

  2. 2

    Extract the list item into a component called ListItem.

  3. 3

    Wrap ListItem in React.memo so it only re-renders when its props change.

  4. 4

    Memoize the filtering with useMemo so it only runs when the search term changes.

  5. 5

    Write handleSelect with useCallback so its reference stays stable between renders.

  6. 6

    Remove any console.log you added before you finish.