页面重新加载

时间:2016-12-12 16:33:55

标签: reactjs react-router react-router-redux

这有点奇怪,我想深究它。

我有一个“产品详细信息”页面,我在其中检查URL是否与特定参数匹配,然后它会继续,否则它应该替换为该特定参数并重新加载页面。

工作正常。但是当我用错误的参数重新加载页面时,条件失败并且页面重新加载了新的参数。但问题是,重新加载后,条件再次失败(路由中仍有最后状态参数状态),因此它会不断重新加载页面。

P.S。我正在检查ComponentWillMount函数中的条件。

以下是我的进一步阐述的代码:

componentWillMount() {
    if (!matchParam(this.props.category, this.props.param) {
      this.props.dispatch(push(this.props.param));
      }
  }

0 个答案:

没有答案
相关问题