react組件的生命週期大體分爲三種狀態react
其中除了unmounting每一個狀態又有對應的will 和 did 方法共有5個函數。函數
除此以外還有兩個特殊的方法shouldComponentUpdate(state或者props改變時會觸發的函數)以及componentWillReceiveProps(props改變會觸發的函數)spa
它們的執行順序分別是component
初始化(init render):生命週期
getDefaultProps => getInitalStates => componentWillMount => render => componentDidMountget
props變化:it
componentWillReceiveProps => shouldComponentUpdate => componentWillUpdate => render =>componentDidUpdate渲染
state變化:date
shouldComponentUpdate => componentWillUpdate => render => componentDidUpdate方法
這裏能夠看出,Props 比 State 的改變會有多出一個componentWillReceiveProps的回調方法