第二階段 更新(屬性&狀態)


§ componentWillReceiveProps:元件將獲得屬性

组件的 props 属性可以通过父组件来更改,componentWillReceiveProps 将来被调用。
可以在这个方法里更新 state,以触发 render 方法重新渲染组件。


§ shouldComponentUpdate:應該?元件更新 *

該方法是非必須的,並且大多數情況下沒有在開發中使用。


§ componentWillUpdate:元件將要更新 *

在組件接收到了新的 props 或 state , 即將進行重新渲染前會被調用,注意不要在此方面裡再
去更新 props 或 state。


§ render :渲染 *

 就是當每次 props 或是 state 被改變時,就會被執行一次


§ componentDidUpdate:元件已完成更新

 在組件重新被渲染之後,componentDidUpdate 會被調用。可以在這裡訪問並修改DOM。

results matching ""

    No results matching ""