Overview
Netflix users love to revisit their favorite shows and movies, often checking their watch history to find content they previously enjoyed or to continue a series. This problem focuses on building a performant and user-friendly interface for displaying a potentially very long list of a user's watch history. Candidates will implement an infinite scrolling mechanism combined with a debounced search feature, crucial for a seamless user experience on large datasets.
What you need to do / Task
Your primary task is to develop a React component that displays a user's watch history. This component must integrate the following features:
- Infinite Scroll: As the user scrolls towards the bottom of the list, automatically load and append more watch history items.
- Search Functionality: Provide a search input that allows users to filter watch history items by their title. The search should dynamically update the list based on user input.
- Debounced Search: To prevent excessive API calls, the search input must debounce user input. Only trigger a search request after a user has paused typing for a specified duration.
- Loading and Error States: Clearly indicate when new data is being fetched (e.g., at the bottom of the list) and handle potential errors during data retrieval.
- "No More Results" State: Inform the user when all available watch history items have been loaded and there are no more to display.
UI/UX expectations
- The page should display a search input at the top, followed by the list of watch history items.
- Each watch history item should minimally display its
title, watchedAt date, and a thumbnailUrl.
- The list should be scrollable, with new items appearing as the user scrolls down.
- A clear loading indicator (e.g., "Loading more...") should appear at the bottom of the list when new data is being fetched.
- An informative message (e.g., "No more watch history items.") should be displayed when all items have been loaded for the current search query.
- In case of an API error, an error message (e.g., "Failed to load watch history. Please try again.") should be displayed gracefully.
Acceptance criteria
- Initial load displays the first page of watch history items.
- Scrolling to the bottom of the visible list triggers the loading of the next page of items.
- The loading indicator is visible when new data is being fetched and hidden otherwise.
- Typing into the search input filters the list after a brief delay (debounce period).
- Rapid typing in the search input does not trigger multiple immediate data fetches; only the last input after the debounce period triggers a fetch.
- When all items matching the current search query are loaded, a "No more results" message is shown, and further scrolling does not trigger new fetches.
- If
fetchWatchHistory simulates an error, an error message is displayed, and infinite scroll/search attempts do not crash the UI.