Saturday, June 6, 2015

Cliff Notes for React.js Component State



  • Mutate State only using the provided methods.  (e.g. setState())
  • In the render method retrieve properties with  "this.state.varname"

https://facebook.github.io/react/docs/component-api.html

  • Refs to include any child components as "state"
  • Warned "By default, use the Reactive data flow and save refs for use cases that are inherently non-reactive"
https://facebook.github.io/react/docs/more-about-refs.html


To ponder further:
"Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. Placing the state there often eliminates any desire to use refs to "make things happen" – instead, the data flow will usually accomplish your goal."

And data flow is well described here:
https://github.com/facebook/flux


No comments:

Post a Comment