React的生命周期

2021-06-29  本文已影响0人  kzc爱吃梨
image.png 更新视图

shouldComponentUpdate -> componentWillUpdate -> render() -> componentDidUpdate -> componentWillUnmount(组件死完前调用)

mount之前不能setState

shouldComponentUpdate有什么用?为什么它很重要?

shouldComponentUpdate允许我们手动进行判断是否要进行组件更新,根据组件的应用场景设置函数的合理返回值能够帮我们避免不必要的更新。

上一篇 下一篇

猜你喜欢

热点阅读