React Query state management
Can other states management tools be ignored over
React Query
being used for state management in a react application?5 Replies
Hi! Quick question, what do you mean by
ignored
? Are you looking for alternatives or replace other options for React Query?React Query is like any other State management, just specialized in, well - querying ( get, post, put, delete )
For any other type of State management, you can try out Redux or Recoil
Ive seen some people saying it can be used for state management, they will even say you dont need redux and the like and im confused
I have tried redux couple of times
I think that
asynchronous state management
fits better. In react, we often need to use useEffect
along with useState
to store and/or display asynchronous data. Depending on your requirements, you will face some issues that will consume more of your time to solve: infinite loops, component not re-rendered, etc. React query is great to not worry about those common issues, so you can move faster.
Can you use it as a global state manager? You can try, but it's not necessary to overcomplicate your solution. You can find extra information here: https://tanstack.com/query/v4/docs/react/guides/does-this-replace-client-state
This is a bonus, but you have an extra option: Jotai x Tanstack Query (https://jotai.org/docs/integrations/query). Might be interesting for you to take a look.Does TanStack Query replace Redux, MobX or other global state manag...
Well, let's start with a few important items:
TanStack Query is a server-state library, responsible for managing asynchronous operations between your server and client
Thank
you