繁体   English   中英

React router Link正在更改URL,但实际上并未重定向

[英]React router Link is changing the url but not actually redirecting

我正在使用react-router。 它工作正常,但如果我只是在url中更改:id,它不会重定向页面

 <Route path="/school/:id" component={School}/>

例如:如果我已经在学校页面上使用网址“school / 234”,我点击另一个链接,网址为“school / 908”。 它不起作用。 网址确实发生了变化,但内容却没有

你基本上可以尝试这个

componentDidUpdate(prevProps) {
    if (this.props.match.params.postId !== prevProps.match.params.postId) {
      discussionId = this.props.match.params.postId;
      this.props.getSomeData(discussionId);
    }
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM