Replies: 1 comment 2 replies
-
when you change the query key (inputs in trpc), you create a new cache entry. That cache entry will then be filled with initialData if you provide it. So, the solution is to only provide initialData if you actually want to see it for a given query. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm using tRPC which uses TanStack Query (v4) under the hood.
I have an issue where the initialData (provided via SSR) is being shown whenever I change the query inputs (
filterState
, orcurrentpage
). It is denounced.I only want the
initialData
to be used and shown for the initial load - I also am not interested in caching as most of the data here changes moment to moment.I've scoured the docs and tried to use a bunch of different options to get it to not show initialData (preferably, it would just keep whatever data was last shown) when the query is refetched.
I tried specifying that
initialData
only be available when the defaults are used (which I think is an ugly solution, but it's the solution in this discussion.But I get this error, which means absolutely nothing to me. I assume it's because tRPC wants the type to not be undefined, which is weird since it'll be undefined by default if I don't fill it, right?
What should I do here? Even if I solve the TypeError above (Typescript does not complain in the editor, only in the browser), it's still a gross solution.
Beta Was this translation helpful? Give feedback.
All reactions