React application development flow:
- Break the app into components
- Build a static version of the app
- Determine what should be stateful
- Determine in which component each piece of state should live
- Hard-code initial states
- Add inverse data flow
- 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>