react生命週期知識點
react生命週期知識點
一個React元件的生命週期分為三個部分:例項化、存在期和銷燬時。
例項化
元件在 客戶端 被例項化,第一次被建立時,以下方法依次被呼叫:
1、getDefaultProps 2、getInitialState 3、componentWillMount 4、render 5、componentDidMount
當元件在 服務端 被例項化,首次被建立時,以下方法依次被呼叫:
1、getDefaultProps 2、getInitialState 3、componentWillMount 4、render