Replies: 1 comment 7 replies
-
the problem is that you're observing the same key. it becomes apparent when you add the devtools. not-existing filters is the same as If you split that apart, it works as expected: https://codesandbox.io/s/trusting-tess-sg4tll?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello 👋🏻
I have a following case:
There are multiple widgets on the page that use the same custom query hook.
Some of the widgets pass filters hash to
queryKey
array and use those filters as a part of actual GET request.However, filters are being populated asynchronously, so some of the queries are disabled until the filters are ready.
The issue is: despite disabling some queries, there is still data being returned from the cache, which is not what the widget should render.
I've prepared a sandbox to better show this:
https://codesandbox.io/s/keen-grass-zqbmt1?file=/src/App.js
Notice how the data is being displayed:
Raw data
is being fetched right at the start without any filters and properly displayed.Filtered data
takes data from cache and displays it, but this is not the data that should be shown there. After the filters are ready, the query is being refetched and proper data is being rendered.The question is: is it possible to prevent taking data from the cache, if the query is disabled? In this case, I would expect
isLoading
to betrue
until the query is enabled again.Beta Was this translation helpful? Give feedback.
All reactions