首页 文章

使用正确的内容调用componentWillUpdate()和componentDidUpdate(),渲染不会更新

提问于
浏览
0

我有这个反应组件:https://gist.github.com/emilevictor/007a10aa1669829feb940b9548e582a1

我拍摄了一个redux传奇,从服务器上获取一些数据 . 它已在this.props.statistics中成功设置,并触发重新渲染 . 在redux中更改状态时,按以下顺序正确调用这些函数:

componentWillUpdate(...)render(...)componentDidUpdate(...)

话虽如此,DOM并没有改变以反映this.props.statistics中的新数字 . 有谁知道可能会出错?

1 回答

  • 0

    这是由于这两行:

    const LayoutWrapper = props => (
      <ChartWrapper>
        <Async
          load={import(/* webpackChunkName: "ReactChart2-layoutWrapper" */ "../../../components/utility/layoutWrapper")}
          componentProps={props}
        />
      </ChartWrapper>
    );
    
    const PageHeader = props => (
      <Async
        load={import(/* webpackChunkName: "ReactChart2-pageHeader" */ "../../../components/utility/pageHeader")}
        componentProps={props}
      />
    );
    

    一旦删除,他们就解决了这个问题 . 我会更加详细地了解它为什么会产生这种效果 .

相关问题