Skip to content
Frontend live coding · 40 minutes

Infinite list with IntersectionObserver

Build a list in React that loads more items as the user scrolls, in 40 minutes. Use a public test API with pages, or a fake function that returns 20 items after a delay and ends after 5 pages. Use IntersectionObserver on an element at the end of the list, not a scroll event listener. Show loading, error and end-of-list states. Explain your decisions while you code, as in a live round.

Requirements

  • The first page loads on mount; the next page loads when a sentinel element at the end of the list becomes visible
  • Only one request runs at a time, and no page is added to the list twice
  • A loading indicator shows at the end of the list while a page loads
  • After the last page, loading stops and an end message is shown
  • A failed request shows an error with a Retry button and keeps the loaded items
  • The observer is disconnected when the component unmounts
  • Items have stable keys from their ids

What reviewers look for

What reviewers look for, the checklist and the stretch goals opens with a year in the app. What a year includes