Alex Dai Playground

[React] component lifecycle

| Comments

React component 的生命週期

第一次執行

  • componentWillMount(元件準備寫入DOM)
  • render
  • componentDidMount(元件已被寫入DOM,此時可以操作DOM元素,整合其他第三方套件、發送AJAX請求)

變更 state or props

  • componentWillReceiveProps
  • shouldComponentUpdate (判斷是否要更新,是才往下執行)
  • componentWillUpdate
  • render
  • componentDidUpdate

http://andyyou.logdown.com/posts/178998-reactjs-assembly-operation-and-life-cycle

Comments

comments powered by Disqus