-----------------------------------React舊版的生命周期-----------------------------------------------------------
-
初始化階段:由ReactDOM.render()觸發------------初次渲染
1.constructor()
2.componentWillMount()
3.render()
4.componentDidMount() 一般在這個里面做一些初始化的事情,如定時器,發送網路請求,訂閱訊息
-
更新階段:由組件內部this.setState()或父組件render觸發
1.shouldComponentUpdate() 控制組件更新的閥門 默認為true false則狀態不更新
2.componentWillUpdate()
3.render()
4.componentDidUpdate()
-
卸載組件:由ReactDOM.unmountComponentAtNode()觸發
1.componentWillUnmount() 一般在這個里面做一些收尾的事情,如關閉定時器,取消訂閱訊息

-
---------------------------------------------------------這是一條分割線----------------------------------------------------------------------------------
-----------------------------------------------------------------React新版本的生命周期----------------------------------------------------------------------
-
初始化階段:由ReactDOM.render()觸發------------初次渲染
1.constructor()
2.getDerivedStateFromProps()
3.render()
4.componentDidMount() 一般在這個里面做一些初始化的事情,如定時器,發送網路請求,訂閱訊息
-
更新階段:由組件內部this.setState()或父組件render觸發
1.getDerivedStateFromProps()
2.shouldComponentUpdate() 控制組件更新的閥門 默認為true false則狀態不更新
3.render()
4.getSnapshotBeforeUpdate()
5.componentDidUpdate()
-
卸載組件:由ReactDOM.unmountComponentAtNode()觸發
1.componentWillUnmount() 一般在這個里面做一些收尾的事情,如關閉定時器,取消訂閱訊息
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/547966.html
標籤:其他
上一篇:分享我通過 API 賺錢的思路
