使用Immutable shouldComponentUpdate进行React-Router重新渲染

时间:2015-12-18 15:46:56

标签: javascript reactjs immutability react-router

当我切换到不同的路线然后回到我的组件时,我遇到了重新渲染组件的问题。 我正在使用React 0.14.3,react-router 1.0.2和Immutable.js。

原因是,我在shouldComponentUpdate方法中比较道具。

shouldComponentUpdate(nextProps, nextState) {
    return !Immutable.is(nextProps.articles, this.props.articles);
}

如果我改变路线并返回,props.articles不会改变,但我还是需要重新渲染页面。

问题是,如果路线刚刚改变,我需要在shouldComponentUpdate方法中考虑什么来跟踪?

提前致谢! 波多黎各

0 个答案:

没有答案
相关问题