ReactJS - 组件的生命周期

组件的生命周期分为三个状态

Mounting: 已插入真实DOM
Updateing: 正在被重新渲染
Unmounting: 已移出真实DOM

React 为每个状态都提供了两种处理函数,即函数在进入状态之前调用(will函数),函数在进入状态之后调用(did函数),三种状态共计五中处理函数。

componentWillMount()
componentDidMount()
componentWillUpdate(object nextProps, object nextState)
componentDidUpdate(object prevProps, object prevState)
componentWillUnmount()

此外,React还提供了两种特殊状态的处理函数

componentWillReceiveProps(object nextProps): 已加载组件收到新的参数时调用
shouldComponentUpdate(object nextProps, object nextState): 组件判断是否重新渲染时调用
posted @ 2017-06-19 15:41  安果果  阅读(162)  评论(0编辑  收藏  举报