将心比心,方得人心~

使用shoulComponentUpdate对子组件的渲染优化

周洲 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 

我是有底线的