React的本质是什么?
- UI = f(data)
- 一切都是组件
- 声明式编程
JSX的优势与局限
- Yahoo推行各司其职,Facebook却逆天而行
- Inline-CSS的思想,使组件完全解耦
- 繁琐的配置与编译,让JSX无法成为ECMA标准
- 但是没关系,有了Babel便可无视标准
使用props还是state
传递外部参数,修改内部状态
详解React组件的生命周期
- mount过程:组件从无到有
- update过程:分为内部或外部引发
- unmount过程:组件从有到无
mount过程
- getDefaultProps
- getInitialState
- componentWillMount
- render
- componentDidMount
因state改变引发的update过程
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate
因父组件想要render这个组件改变引发的update过程
- componentWillReceiveProps
- shouldComponentUpdate
- componentWillUpdate
- render
- componentDidUpdate