preloaded data with paginated query
Hello, I was wondering if there was an official way of preload loading data for a paginated query in nextjs? With regular queries I can just use the
usePreloadedQuery()
hook, but I don't see an equivalent for paginated queries.5 Replies
anime/page.tsx
anime/_components/anime-list.tsx
Here's what I've come up with but I'm not sure if this is what is intended to be done.
edit: I've realize this approach wouldn't work with the load more function.
I've ended up with this which seems to work well enough.
@ballingt @ian would you have any insights on this?Yeah I think that's a good approach. You could maybe replace the useState / useEffect with a ref:
Though I haven't used / tested this
hmm interesting will definitely take a look at this. Thank you for the info as always!
I think you need neither useEffect nor useRef:
Give it a go and let us know if it works.
Yep that works perfectly, thank you for the great suggestion!