RN生命周期函数
第一次加载时:
getInitialProps
getInitialState
componentWillMount
render
componentDidMount
--Running--
运行过程中改变state
shouldComponentUpdate
componentWillUpdate
Render
componentDidUpdate
--running--
注:以上函数里面都不能setState,否则会造成死循环
运行过程中改变props
componentWillReceiveProps
shouldComponentUpdate (包含一些属性,nextProps,nextState,因为新的渲染还没开始,所以是next…)
componentWillUpdate (包含一些属性,nextProps,nextState)
Render
componentDidUpdate (包含一些属性,prevProps,prevState,这里因为新的渲染已经结束,所以是prev...)
--rendering--
网友评论