React 生命週期函式

2021-08-29 03:13:38 字數 838 閱讀 6731

initialization (初始化)

mounting(掛載)

updation(更新)

unmounting()

setup

componentwillmount

props

states

componentwillunmont(當這個元件即將被從頁面中移除的時候,會被執行)

props

render

componentwillreceiveprops

shouldcomponentupdate

state

componentdidmount(元件被掛載到頁面之後,自動被執行)

shouldcomponentupdate(元件被更新之前,會自動被執行)

componentwillupdate\\

componentwillupdate

render\\

\render

componentdidupdate\\

\componentdidupdate(元件更新完之後,執行)\\

componentwillreceiveprops

乙個元件要從父元件接受引數

只要父元件的render函式被重新執行,子元件的這個生命週期函式就會被執行

React生命週期函式

說來慚愧,準大四計算機專業學生黨第一次寫技術部落格。以前學東西沒有記錄的習慣總是容易忘記。最近在看老師的教程學習react框架,想寫點東西記錄一下學習的過程。若寫的不好,各位大佬見諒了,歡迎指正。什麼是生命週期函式?生命週期函式就是元件某一時刻會自動執行的函式。initialzation 初始化 m...

react生命週期函式

生命週期函式 某一時刻元件會自動呼叫執行的函式 render也是 initialization 初始化 constructor裡 mounting 掛載 componentwillmount 接下來render 生命週期函式的使用場景 不可缺少的乙個生命週期函式是render 效能優化 減少無謂的渲...

react生命週期函式

和vue一樣react也有在某乙個時刻會對應執行的生命週期函式。這裡我將react的生命週期分為三大部分 初始化生命週期 compionentwillmount 元件即將被掛載到頁面前執行 render 元件渲染 componentdidmount 元件掛載到頁面上時執行 props和state更新...