That's right - you can do it with setQueriesData. I just meant that the code I wrote in the example doesn't handle it :). If you want to go that route it's perfectly fine. The biggest advantage of invalidation is the simpler code and that you don't push data down for queries that aren't even used.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Actually it does handle addition and deletion:
There is
queryClient.setQueryData
for addition.And for deletion it's possible to use
setQueriesData
- I'm using it with arrays of items:Unless I'm doing it wrong ?
Thanks for this react-query websocket starter guide. 👍
That's right - you can do it with setQueriesData. I just meant that the code I wrote in the example doesn't handle it :). If you want to go that route it's perfectly fine. The biggest advantage of invalidation is the simpler code and that you don't push data down for queries that aren't even used.