react组件生命周期:
- constructor
- componentWillMount
- render
- ComponentDidMount
- componentWillReceiveProps
- shouldConponentUpdate
- componentWillUpdate
- componentDidUpdate
- componentWillUnmount
普通的react组件,一般会依次经历一下阶段:
- constructor
- componentWillMount
- render
- ComponentDidMount
当react组件内部state有更新时:
- shouldConponentUpdate (当shouldConponentUpdate返回值为false的时候,之后的生命周期不会执行)
- componentWillUpdate
- render
- componentDidUpdate
当react组件接收的props值有更新时:
- componentWillReceiveProps
- shouldConponentUpdate (当shouldConponentUpdate返回值为false的时候,之后的生命周期不会执行)
- componentWillUpdate
- render
- componentDidUpdate
删除react组件:
- componentWillUnmount