Replies: 2 comments 1 reply
-
You cannot retrieve data from the query cache using a query key that has never been used in an actual query. I presume you have not defined a query using the The official example mutate an item that was returned by a query that fetched that specific item. What you are trying to do is mutate an item that was returned by a query that fetched a collection of items. What may work for you: const previousTechnology = queryClient.getQueryData(['technologies']).find(technology => technology.id === technologyId); |
Beta Was this translation helpful? Give feedback.
-
what if I have the vice-versa? I have query with |
Beta Was this translation helpful? Give feedback.
-
Hello.
I see in your example you are getting one item from a list https://react-query.tanstack.com/guides/optimistic-updates#updating-a-single-todo
I am trying to do the same but with no luck.
I have a query with a key, like this
and I have a mutation where I am trying to get one item, like this:
Did I misunderstand your example, or should my list be in a definite shape? Because if I do it this way, it will always give
undefined
If I do
It will work, but will give entire list, but I want to get one item.
Is it possible? Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions