How to initiate search params from initial api response without triggering re-fetch?
1. I fetch initial data via
/data endpoint.
2. /data returns parameters that come with some initial parameters (let's say { page: 1 })
3. I add these parameters from the response to the url address as search params so I can use them via useSearch in the UI (e.g. to show we're on Page: 1)
4. Search params changed which are part of the respective /data query keys and re-trigger the query basically returning the exact same thing as without any search params.
What's best to do when you want to solely rely on search params as your state manager in this case WHILE preventing a re-trigger of the query because setting initial search params changed query keys?7 Replies
magic-amber•2y ago
you could use the
shouldReload functionmute-goldOP•2y ago
thanks @Manuel Schiller ! Would that also work if I did not use
loaderDeps and loader?
Could you also roughly outline what that would look like? I assume you must somehow validate initial params against incoming params and if they equal, return false?magic-amber•2y ago
yeah that sounds like it would work
hm if you don't use loader, what triggers the fetch?
mute-goldOP•2y ago
a
useQuery, which receives search params from useSearchmagic-amber•2y ago
so it's really a react query question 😁
mute-goldOP•2y ago
Yeah I kinda realized that mid way too. I'm sorry 🙈
magic-amber•2y ago
no problem. just ask in their channel again