<p>
具体参考这篇文章:
http://www.race604.com/react-native-component-lifecycle/
<p>
render():
render 保持其 pure 特性(纯粹的渲染)
- 不修改组件state
- 不操作dom,浏览器交互
按照这样方式,可以使得服务端渲染可行,react-natve可行
getInitialState()
组件挂载之前调用一次 返回值为this.state的初始值
componentWillMount() 和 componentDidMount()
componentDidMount : 初始化渲染之后调用
通过 this.getDOMNode() 来获取相应 DOM 节点
可以发送ajax
与其他框架集成
componentWillMount : 初始化渲染之前调用
componentWillReceiveProps
在组件接收到新的 props 的时候调用。在初始化渲染的时候,该方法不会调用。
用此函数可以作为 react 在 prop 传入之后, render() 渲染之前更新 state 的机会。老的 props 可以通过 this.props 获取到。在该函数中调用 this.setState() 将不会引起第二次渲染。
提示
Warning: Any use of a keyed object should be wrapped in React.addons.createFragment(object) before being passed as a child