React-生命周期的相关介绍

1.mounting/组件插入相关

(1)componentWillMount  模板插入前

(2)render 模板插入

(3)componentDidMount 模板插入后

2.Updating/组件更新相关的

(1)componentWillReceiveProps (Object  nextProps)

(2)shouldComponentUpdate(Object nextState , Object nextProps)

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

(3)componentDidUpdate(Object preProps , Object preState)

组件已更新

3.UnMounting/组件移除相关

(1)componentWillUnmount

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

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

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

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

 

posted on 2017-08-30 09:42  liminshen  阅读(111)  评论(0编辑  收藏  举报