DEV Community

Mihai Dumitru
Mihai Dumitru

Posted on

[Discussion] Managing state in React

Hi community,

Currently I am following some tutorials about ReactJS and I am at the point of learning how to manage state. For this we can use libraries like Redux or the newer useState() hook.

What is your opinion / best practices about this topic, are the hooks the way to go from now on?

Top comments (2)

Collapse
 
dance2die profile image
Sung M. Kim • Edited

For local or sub-contexts, you can simply use useState/useReducer or Context API.

For global states... it is a heated topic.

To provide a few libraries, I can think of are,

  1. React-Query: Provides hooks and supposedly you don't have to manage "global states" (sorry haven't used this).
  2. Zustand: tiny but easy to use! (redux devtool supported)
  3. Redux Toolkit: created and maintained by Redux team

There are lotcha others (github.com/GantMan/ReactStateMuseum) but check'em out during spare time... Just way too many.

Collapse
 
psiho profile image
Mirko VukuÅ”ić

I use neither. I prefer Mobx 90% of the time. Regaining 10% is useState and it's only for small, local states