Lazy loading list from API
i am trying to list the items from api in cards, api is paginated, so i have used my senior's code where he has created custom hook to fetch data whenever the last card comes using intersection observer, the observer working fine, the state which is used for page_number is updating properly but when i call the next set of data, instead of latest state value, old value is going, not sure why that is happening, eg. initial page number is 1, after fetching data , state changed to 2(checked with useEffect), once the last card comes, when i hit api again , its going as 1 instead of 2. can anyone help me regarding this.
1 Reply
onNext function only not working as i want
what could be the issue
can anyone help me on this