T
TanStack3y ago
rare-sapphire

followed pagination example from tanstack site, but not working, any feedback please?

Stack Overflow
react pagination using tanstack react query, buttons are not working
I am using jsonplaceholder api and trying to fetch results on different pages, for that I am using tanstack react query, however my buttons seem to not work? Can somebody please guide me in the right
3 Replies
foreign-sapphire
foreign-sapphire3y ago
Did you fix the issue you found with the state not being updated?
on further troubleshooting , in next button onClick
setPage((old)=>(data?.hasMore? old +1 : old))
setPage((old)=>(data?.hasMore? old +1 : old))
is not updating the state
rare-sapphire
rare-sapphireOP3y ago
no it only works if I do it setPage((old)=>old+1) also looks like useEffect is not required..
foreign-sapphire
foreign-sapphire3y ago
If you console.log data?.hasMore, what do you get?

Did you find this page helpful?