Question

Which guiding principle can be used when designing the *state* shape of a component?

#react

Answer

The principle of *minimalism*, by which the shape of the state should be the minimal representation of the data needed. If something can be derived from either *props* or *state*, it probably shouldn't be in the state.

[^1]: https://reactjs.org/docs/lifting-state-up.html
[^2]: The same principle is applicable when designing Redux state https://redux.js.org/basics/reducers#designing-the-state-shape

Learn

Author

xavi

Reviews
Last
next

Students 1