Paste_Image.png
<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