1. 程式人生 > >react入門筆記七 (元件的生命週期)

react入門筆記七 (元件的生命週期)

生命週期分三個狀態

mounting(元件掛載階段)

updating(元件更新)

unmounting(元件移除)

props與state

 

 

 

 

生命週期分四個階段

建立階段

 

例項化階段

getInitialState

componentWillMount

render

componentDidMount

 

更新狀態

componentWillReceiveProps

shouldComponentUpdate

componentWillUpdate

render

componentDidUpdate

 

銷燬階段

compoentWillUnmount(即將銷燬)

 

生命週期執行順序

元件第一次建立時

元件建立並更新

元件銷燬時