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屬性的默認值

相關文章
相關標籤/搜索