我们在渲染父组件的时候对子组件的render渲染,可以通过shouldComponentUpdate进行处理是否需要对子组件进行渲染。
shouldComponentUpdate(nextProps, nextState) { if (nextProps.content !== this.props.content) { return ture; } else { return false; } }
说明:content指的是子组件接收的某个参数。
将心比心,方得人心~
周洲 2020-09-07 14:45:53
我们在渲染父组件的时候对子组件的render渲染,可以通过shouldComponentUpdate进行处理是否需要对子组件进行渲染。
shouldComponentUpdate(nextProps, nextState) { if (nextProps.content !== this.props.content) { return ture; } else { return false; } }
说明:content指的是子组件接收的某个参数。
『微信打赏』
Tag标签: react
上一篇: 限制父组件传递到子组件元素的类型
下一篇: 关于React的思考