Put in order · JavaScript and React course · Module 11: Data Fetching and APIs

Infinite Scroll Implementation Steps

Arrange the steps for implementing infinite scroll with IntersectionObserver in order:

Items to put in order

  • Increment the page number (setPage)
  • Define a callback ref for the last list element
  • Create a ref with useRef() for IntersectionObserver
  • IntersectionObserver detects the visibility of the last element
  • useEffect fetches the new page and appends data to the list

You can check the correct answer by solving this task in the CodeWorlds game.