我正在使用reactjs和react router。 我已将路由器创建为:
ReactDOM.render(
<Router history={browserHistory}>
<Route exact path="/" component={App} />
<Route path="/:id" component={User} />
</Router>,
document.getElementById('root')
);
在应用程序组件中,我有一个指向 "/:id"
路径的链接:
<Link to={'/'+id} >
当我在“/” route 时,我的 View 工作正常,但现在当我单击链接时,路径发生变化,我的 View 瞬间发生变化,然后在应用程序组件中给出错误(它是另一条路线)。
我使用"react-router": "^2.8.1"。
PS: the error is in the setinterval function in the component {App}.
感谢您提前提供的帮助
最佳答案
尝试在顶部使用它:
import { Link } from 'react-router-dom'
引用这个:https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/Link.md
关于reactjs - 如何使用 <Link> react 路由器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46421496/