Question about using React Query as a global store
Hi team,
We’re currently using React Query as a sort of client-side store or global state in our application. Here’s a simplified example:
We then update the state via
My questions are:
1. Could using React Query this way (as a client-side global store) cause performance issues, especially at app startup?
2. Are there any risks or anti-patterns in using React Query purely for client state instead of server state?
Our supervisor believes this approach is fine, but I wanted to confirm best practices with the community.
We’re currently using React Query as a sort of client-side store or global state in our application. Here’s a simplified example:
We then update the state via
setQueryData. Sometimes, developers also attach the queryClient to the window object to update the cache globally.My questions are:
1. Could using React Query this way (as a client-side global store) cause performance issues, especially at app startup?
2. Are there any risks or anti-patterns in using React Query purely for client state instead of server state?
Our supervisor believes this approach is fine, but I wanted to confirm best practices with the community.