Skip to content
Discussion options

You must be logged in to vote

it's a good question. It's because the observer (your useQuery "instance") is not really "mounting". It is mounting with an empty search value. Then, the search value changes from empty string to t. At that point, the observer is already mounted - it just switches from one cache entry to another.

There isn't really a flag to disable refetches for this "event". I know rtk-query combines the two with refetchOnMountOrArgChange. My suggestion is to always set staleTime to something you're comfortable with and take it from there without altering the flags, as caching is more "time-based" than "event-based". The refetch only happens because your staleTime is 3 seconds. That means data is not fr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Djordjenp
Comment options

Answer selected by Djordjenp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants