Replies: 2 comments 4 replies
-
Hi 👋 I don't really understand the question but updating the query programmatically should automatically update any observers. Please could you provide a reproduction? |
Beta Was this translation helpful? Give feedback.
-
@louis-young Solution 1) This is working
Solution 2) This is not working (without useQuery at the top of the component and without invalidateQueries):
Solution 3) If a mix both useQuery and setQueryData, setQueryData even I set locally the cache, on refresh when component renders and runs useQuery, I set initialData or placeholderData, with the data set by setQueryData previous, and while the fetching is happening the initialData is actually old data. I expect to set data with setQueryData and the component to rerender without extra invalidate query function, as I have all the data in place, and if I hit refresh and I have persister provider, when I fetch data for backend for any reason and set initialData, the data to be the one I lastly set, and not some old cache data. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
What is the best way to update query cache key and rerender React component?
Let's say that the on bootstrap of the app some key is set with some initial data, instead GET.
Later after some change on the frontend, POST/PUT/PATCH, update the cache locally, with refreshing only that key, I don't need invalidate.
This set of actions, setQueryData(['someKey']) and then refreshQueries(['someKey']) is not working as it should and React component is not rerendering.
The other solution setQueryData(['someKey']) and then invalidateQueries(['someKey']) works, but I need to call useQuery in some nested component down the tree so rerender can work, which I don't like.
version: 4.26.1
BR,
Beta Was this translation helpful? Give feedback.
All reactions