Home > Net >  What is the difference between updateQueryData() and patchQueryData() in Redux Toolkit Query?
What is the difference between updateQueryData() and patchQueryData() in Redux Toolkit Query?

Time:06-26

Why do we need the API patchQueryData() in Redux Toolkit Query?

I can't see how it is different from updateQueryData() on the official documentation here.

CodePudding user response:

patchQueryData applies an "immer patch" to the cache entry, while updateQueryData allows you to run a function against your cache entry and just "change" it. Internally, that will create a patch and then call updateQueryData. So, essentially patchQueryData is an implementation detail. It will not be useful for most people, but some people might see benefit in it, so it is exposed as well.

  • Related