React-强制刷新(获取render后的内容)

React-强制刷新(获取render后的内容)

setState 是不保证同步的,如果需要在 setState 后直接获取修改后的值,可以:

使用setTimeout

componentWillReceiveProps(nextProps, nextContext) {
    this.setState({
      caseDetail: nextProps.caseDetail
    });
    setTimeout(this.changeHeight, 0);
  }

参考内容(上面有很多的方法):https://www.cnblogs.com/little-ab/articles/6958852.html

发布了35 篇原创文章 · 获赞 1 · 访问量 6718

猜你喜欢

转载自blog.csdn.net/qq_36162529/article/details/90715982