TanStackT
TanStackโ€ข3y agoโ€ข
73 replies
full-green

reset query with `keepPreviousData` to `isLoading` when query-key changes

Hey there,

maybe I'm totally handling this wrong but I tinkered with this problem quite a bit now and can't get to the solution. Maybe it's even a bug?!

I created this sandbox to illustrate my problem https://codesandbox.io/p/sandbox/reactquery-with-keeppreviousdata-6eg4bp?file=%2Fsrc%2Findex.jsx
In my app I want to switch a parent entity who's ID is part of the query-key as the results of a fetch-request are based upon this ID (displaying siblings of that entity). Also the siblings can be filtered by using a filter string.

Before filtering when changing the entities the loading state is correctly shown (IMO). But once I filtered the loading state is never shown again - despite of having or not having a filter when switching entities.

Hope this all makes sense and someone can enlighten me. ๐Ÿ™‚
Thanks
CodeSandbox is an online editor tailored for web applications.
reactQuery with keepPreviousData
Was this page helpful?