createInfiniteQuery runs fetch, when initialData is defined
Hello, I have a main page in SvelteKit that has the following structure:
+page.svelte
And in the +page.server.js
:
I have defined the initial data as the actual data
that it's retrieved on the Page Load, that corresponds to the first set of articles or recipes.
Given the initial data is set in the createInfiniteQuery
, Is there any reason for this or workaround so that it doesn't try to fetch again the data that was fetched from the server?
3 Replies
secure-lavenderOP•3y ago

sensitive-blue•3y ago
I'm guessing because the query is mounted again on the client. Try setting a non zero staletime to your query like 1000ms or something
flat-fuchsia•3y ago
caching generally seemed to work properly for me when I pass the load function's custom
fetch
to any requests inside load functions instead of the global fetch, e.g something like.
otherwise you can set the staletime
like @Aryan mentioned or refetchOnMount: false
in the query options