DEV Community

Discussion on: Accessing React State right after setting it

Collapse
 
dance2die profile image
Sung M. Kim

Hi @bgadrian , did you mean using libraries such as Redux/MobX?

Collapse
 
bgadrian profile image
Adrian B.G.

That would be one way yes.

The idea is that if you need a state object and the React way is a problem you can move it to a model. I would not recommend it for something simple like your examples of course, just stating that this possibility exists.

Thread Thread
 
dance2die profile image
Sung M. Kim

That sounds like a spot-on idea.

I recently created a small web page and used MirrorJS (uses Redux underneath) to keep all states in one place.

setState wasn't needed in most of places and all the states were managed in one place.