Infinite scroll
Watch the walkthrough
Open on InstagramExercise: Build an infinite-scrolling feed
Render the first page of records, then load the next page when a sentinel near the bottom enters the viewport. Append records without replacing earlier pages. Use a paginated mock API with stable IDs and a deterministic final page.
Requirements
- Keep items, the next page or cursor, loading, error, and has-more state explicit.
- Prevent duplicate requests while a page is loading; deduplicate records by ID.
- Show initial loading, a loading-more indicator, a retry action, and an end-of-results message.
- Disconnect the observer when the component unmounts, and do not append obsolete responses after a feed reset.
Acceptance checks and discussion
Scroll repeatedly under a slow response: each page should be requested once. Retry a failed page without skipping it. Discuss why infinite scrolling still needs virtualization for a very large feed.
The brief above is an original practice specification. The linked sandbox is supporting solution material and may implement a simpler subset of these requirements.