父组件每次改变state,都会触发render,然后触发子组件,如果不用触发子组件可以用

shouldComponentUpdate声明周期控制
 
在子组件里放入:
  shouldComponentUpdate(nextPros) {
    console.log('是否更新了');
    if (nextPros.name== this.props.name) {
      return false;    //如果当前props的值和传过来的值一样就不用触发更新
    }
    return true;
  }

相关文章:

  • 2022-12-23
  • 2021-08-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2022-12-23
  • 2022-02-19
  • 2023-01-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案