Fullstack React Ch2

5th July 2017 at 10:07am
Fullstack React

React application development flow:

  1. Break the app into components
  2. Build a static version of the app
  3. Determine what should be stateful
  4. Determine in which component each piece of state should live
  5. Hard-code initial states
  6. Add inverse data flow
  7. Add server communication

我将最重要的几步加粗了。

React 的 event flow (aka. inverse data flow) 有点烦,子 component 的事件必须一层一层传达到拥有数据的父 component。比如下面的例子,onFormClose 是从父 component 传递下来的:

<button
  className='ui basic red button'
  onClick={this.props.onFormClose}
>
  Cancel
</button>