I just wanted to learn some React, dammit. Which of state management libraries should I learn this week?
Seeing the front-end scene right now, there are many options for everything. Your head is probably also exploding and you’re feeling all too anxuous.
New libraries come and go all the time. You have to start with something, right?.. That’s what all the cool guru kids do and talk about, ain’t it?
So should you start with Redux?
How about… none?
That’s right, not every app needs one.
Even more, though, beginners certainly don’t need one. Why?
Ouch, that kind of sounded harsh. After all, there has to be a reason everyone is using these?
There is, but that’s not the point.
If you are only learning React, you already have a plenty of concepts to wrap your head around. JSX. State. Props. Event handlers. Binding functions. Uni-directional data flow.
Why add dozen more right away? That’s not a smart decision. Chasing a hundred golden goose at once will get you none.
So what do I do, exactly?
You master your React skills at this point. Do a learning project. Something not very basic, but not Facebook-level either.
Instead of googling for a state management library, just put your state right into your components. Don’t worry about it for now! React has a state mechanism for a reason.
Besides that, make sure to also master lifecycle hooks and in general understand how React works. There’s a lot to learn already!
By forcing yourself to focus at one new thing at a time, you’re doing yourself a favor. You will have a far better understanding of how each and every one of your tools works. Where it starts and where it ends. Where it shines and where it sucks.
It’s a common problem for people who try to have everything all at the same time, to have no clear mental map of what’s in React and what’s in Redux.
That get a bit unwieldy to manage?
Learn about the container component pattern and apply it.
Over time, you will, all by yourself, start to see certain patterns emerge in how you deal with state. You will start feeling a certain pain bug you, over and over.
Congrats, you know know, first hand, that something could be better. Something that… could be solved by Redux perhaps. Or MobX. Or whichever. (Which one in particular is not the point.)
Now, create a feature branch and try to Redux everything. If it feels weird to you, try MobX, and try this, try that. See what works better for you.