#Invalidate query doesn't work with beforeLoad query?

17 messages · Page 1 of 1 (latest)

paper lance
#

you are using fetchQuery in beforeload and returning the result as data to the component instead. invalidating the query wont help with reloading data for mounted components, you‘ll probably have to invalidate the router via e.g. router.invalidate()

#

prefetching should still work

#

you need to useQuery on the client to use the prefetched data

#

your main issue is passing down the data with eg fetchQuery which is just a static payload thats sent to the component

#

your existing code will just work when you use router.invalidate() btw as it reruns loaders

#

router = useRouter() for example

#

prefetchQuery returns nothing cause it just preloads data so your useQuery hook has it right away without fetching it.

#

scroll down to the router segment

#

its really intuitive

#

yep and invalidating the single query key should make the useQuery hook refetch

#

with router / start you just pass the props down which is way nicer

#

beware that beforeLoad runs for every segment (eg if that page you open within the layout route is /dashboard/account, it runs for pathless, dashboard and account)

#

loader is what runs for the exact route component

#

you may want to deduplicate these calls

rugged wing