纯组件内部自动实现了钩子函数shouldComponentUpdate钩子,不需要手动进行比较
原理:纯组件内部通过分别对比前后两次props和state的值,来决定是否重新渲染组件
使用方法:
class pure extends React.PureComponent{
render(){
return(
<div />
)
}
}
博客介绍了React纯组件相关知识。纯组件内部自动实现shouldComponentUpdate钩子,无需手动比较。其原理是通过对比前后两次props和state的值,以此决定是否重新渲染组件,还提及了使用方法。
纯组件内部自动实现了钩子函数shouldComponentUpdate钩子,不需要手动进行比较
原理:纯组件内部通过分别对比前后两次props和state的值,来决定是否重新渲染组件
使用方法:
class pure extends React.PureComponent{
render(){
return(
<div />
)
}
}
820

被折叠的 条评论
为什么被折叠?