React-生命周期的相关介绍

1.mounting/组件插入相关component

(1)componentWillMount  模板插入前生命周期

(2)render 模板插入get

(3)componentDidMount 模板插入后it

2.Updating/组件更新相关的模板

(1)componentWillReceiveProps (Object  nextProps)渲染

(2)shouldComponentUpdate(Object nextState , Object nextProps)date

组件判断是否从新渲染的时候调用,组件接收到新的props或者states时候会调用,返回bool方法

(3)componentDidUpdate(Object preProps , Object preState)next

组件已更新co

3.UnMounting/组件移除相关

(1)componentWillUnmount

在组件被移除以前触发,能够用该方法清除一些必要的组件

4.生命周期中与props和state相关

(1)getDefaultProps  设置props属性的默认值

(2)getInitialState 设置state属性的默认值

相关文章
相关标签/搜索