#380 News Board

easy
react

Implement a React component that fetches and displays stories from the Hacker News API.

  • Use the endpoint:

    https://hacker-news.firebaseio.com/v0/topstories.json

    to get a list of top story IDs.

  • For each story ID, fetch the story details from:

    https://hacker-news.firebaseio.com/v0/item/{id}.json

Requirements:

  1. Fetch the list of top story IDs.
  2. Display the stories 5 at a time.
  3. Include a “Load More” button to fetch the next 5 stories.
  4. Show a loading state while fetching.
  5. Show an error state if the API request fails.
  6. On success, display each story’s title as a clickable link to its URL.
  7. Use React hooks (useState, useEffect) to manage state.

Bonus:

  • Disable the “Load More” button when no more stories are left.
  • Handle retries if a fetch request fails.