We are in our fifth week, so far we have learned a lot about React, React Native components, Routing and State. It's time to think about how to manage our State. But why should I care?
State is an important part of the React World. It means, all the components I use should have state? Not, because we already saw stateless components and we saw how they are important and how we can use those. Even though, Stateless components are cool, at some point we will need to use state in our React components.
In today's episode we are going to see some good practices on how to manage our state. Tomorrow, we will see how to manage our state itself.
Let’s start with Dan Abramov, the Redux creator. Probably, you’ve heard about Redux. Redux is a tiny library to help manage state in React components.
This tweet from Dan Abramov explains one important thing:
There are two basic premises:
- Don’t duplicate data from props
- Don’t keep something in the state if you are not using it for rendering
The point is: you should take care of your component’s state. When we start coding in React, normally we don’t care about these things, because we just wanted to create components and plug those. Right now, it’s time to worry about these things, because you’re already know how to do simple things.
There are a bunch of tutorials on internet talking about state in React. Take your time today to read some of them at the resources section.