|
|
|
|
|
by applecrazy
2843 days ago
|
|
The main issue is that React needs state passed around as props otherwise, which becomes unweieldy if you didn’t have a global state. I believe it also makes debugging state issues easier if you have a single source of truth. Edit: this is somewhat alleviated by the introduction of the React Context API[1], which provides some cleaner functionality but requires quite a few extra components in the render tree. [1]: https://reactjs.org/docs/context.html |
|
Context provides a way to pass data through the component tree without having to pass props down manually at every level. https://reactjs.org/docs/context.html
>> single source of truth
Often, several components need to reflect the same changing data. We recommend lifting the shared state up to their closest common ancestor. https://reactjs.org/docs/lifting-state-up.html