0

I have built an app that fetches a list of posts based on selected category. When the category changes I reset state and load a new set of posts based on the new category. I use componentDidMount() to call a fetch data function based on category and componentDidUpdate(prevProps) to check if a new category has been selected. If so I reset data and call the data function again. This works fine except I only want to call the first 50 entries. If a customer triggers an event (window scroll or clocks load more data button) I then want to load and display the next 50 records. This is where I am struggling. any suggestions on the the best way of implementing this?

Rob
  • 1
  • 1
    Are you fetching the data from a REST API or something similar? Does the endpoint support pagination? If so, the response should contain the URL for the next 50 elements. – Code-Apprentice Jun 04 '19 at 21:45
  • Possible duplicate of [React.js best practice regarding listening to window events from components](https://stackoverflow.com/questions/32896624/react-js-best-practice-regarding-listening-to-window-events-from-components) – zero298 Jun 04 '19 at 21:45
  • 3
    do you have any code to talk about? – philipp Jun 04 '19 at 21:46

0 Answers0