× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Keep Component State Centralized

Michelle Tilley
Dec 19, 2015
<p>Remember that small components without a lot (or any!) internal state are easier to reason about, reuse, and test. Whenever you have a tree of components, try to keep as much of the state as you can—especially "global" state that is shared and edited by multiple components in the tree—in a top-level component, and pass pieces of the data, as well as callbacks to modify that data, as properties to the other components.</p> <p>If this starts to get cumbersome, you may consider completely externalizing your state and using a library that offers tools for helping to manage that complexity, such as <a href="http://redux.js.org/">Redux</a>.</p>
comments powered by Disqus