react的生命週期
安裝:創建組件的實例將其插入DOM時,將按以下順序調用這些方法:
**constructor()
static getDerivedStateFromProps()
render()
componentDidMount()**
更新:props or state的更改可能導致更新。重新呈現組件時,將按以下順序調用這些方法:
static getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDidUpdate()
卸載:從DOM中刪除組件時調用此方法。
componentWillUnmount()