React生命周期
React生命周期
吴华锦React component lifecycle 生命周期
React的生命周期是component在建立和渲染的过程,以component class出发,React会做以下的过程:
依照component被挂入DOM的过程分类,过程中会依序执行component的函数如下:
Mounting:component被建立实体(即react element)后,渲染到DOM的过程:constructor()static getDerivedStateFromProps()render()componentDidMount()
Updating:当component收到新的props时,更新状态(state),再重新渲染到DOM的过程:static getDerivedStateFromProps()shouldComponentUpdate()render()getSnapshotBeforeUpdate()componentDidUpdate()
Unmounting:当component不被使用,从DOM移除的过程componentWillUnmounted()
Error Handling:当component错误发生时componentDidCatch()
评论
匿名评论隐私政策







