![[无辜呆]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_96.4fb9d71.png)
请教一个react优化问题,我们可以在shouldComponentUpdate中这样比较来避免重新渲染数据吗?比如我们通过JSON.stringify(),比较state数据
shouldComponentUpdate(nextProps, nextState) {
if(JSON.stringify(nextState) == JSON.stringify(this.state)){
return false
}
return true
}
shouldComponentUpdate(nextProps, nextState) {
if(JSON.stringify(nextState) == JSON.stringify(this.state)){
return false
}
return true
}
展开
39
3