1. 程式人生 > >react 的生命周期函數

react 的生命周期函數

bsp dup idm block 生命 nbsp expand 組件 上進

生命周期函數:

是指在某一時刻組件自動執行 的函數

初始化:

設置props和state

mounting:

componentWillMount 在組件即將被掛載到頁面的時候自動執行

render 組件在頁面上進行掛載

componentDidMount 在組件被掛載到頁面的時候後自動執行

updation:組件更新

props

=>componentWillPeceiveProps=>shouldComponentUpdate=> componentWillUpdate=>render=> componentDidUpdate

state

=>shouldComponentUpdate=> componentWillUpdate=>render=> componentDidUpdate

unmounting:

即將被從頁面去除組件的時候

react 的生命周期函數