第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

生命周期問題

父組件掛載三次子組件:生命周期函數(shù)執(zhí)行流程真實(shí)的是這樣的(對(duì)比標(biāo)箭頭的地方)

? ? super constructor

? ? super componentWillMount

? ? super render


? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentDidMount

? ? ? ? ->child componentDidMount

? ? ? ? ->child componentDidMount


? ? super componentDidMount


為什么不是這樣的?

? ? super constructor

? ? super componentWillMount

? ? super render


? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentDidMount

? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentWillMount

? ? ? ? ->child render

? ? ? ? ->child componentDidMount


? ? super componentDidMount


正在回答

1 回答

  • componentWillMount?在渲染前調(diào)用,在客戶端也在服務(wù)端。

  • componentDidMount?: 在第一次渲染后調(diào)用,只在客戶端。之后組件已經(jīng)生成了對(duì)應(yīng)的DOM結(jié)構(gòu),可以通過this.getDOMNode()來進(jìn)行訪問。 如果你想和其他JavaScript框架一起使用,可以在這個(gè)方法中調(diào)用setTimeout, setInterval或者發(fā)送AJAX請(qǐng)求等操作(防止異步操作阻塞UI)。

  • componentWillReceiveProps?在組件接收到一個(gè)新的 prop (更新后)時(shí)被調(diào)用。這個(gè)方法在初始化render時(shí)不會(huì)被調(diào)用。

  • shouldComponentUpdate?返回一個(gè)布爾值。在組件接收到新的props或者state時(shí)被調(diào)用。在初始化時(shí)或者使用forceUpdate時(shí)不被調(diào)用。?
    可以在你確認(rèn)不需要更新組件時(shí)使用。

  • componentWillUpdate在組件接收到新的props或者state但還沒有render時(shí)被調(diào)用。在初始化時(shí)不會(huì)被調(diào)用。

  • componentDidUpdate?在組件完成更新后立即調(diào)用。在初始化時(shí)不會(huì)被調(diào)用。

  • componentWillUnmount在組件從 DOM 中移除之前立刻被調(diào)用。


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
React16.4 快速上手
  • 參與學(xué)習(xí)       40295    人
  • 解答問題       137    個(gè)

結(jié)合實(shí)例帶你快速入門React16基礎(chǔ)語(yǔ)法,并完成Todolist功能開發(fā)。

進(jìn)入課程

生命周期問題

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)