Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
18 replies
Johnson

Make .useInfiniteQuery global

I have an infinite query and 2 different places where I want to have the data/fetch new data. These are my considerations:
1. I can't pass the data via a simple child component (lifting state up) because the other place is a page created via dynamic routes ([id].tsx)
2. I can't make the .useInfiniteQuery reside outside of a component, so I can't really share data via exporting
3. I tried using zustand/jotai to make the data and the fetchNextPage() global. This works as far as getting the first page of data and also running another db query for the second page, but fails when I want to get the data of the second page. (which means I really haven't found a way to get data from this point on)
Was this page helpful?