我的路线如下:
render(
<Provider store={store}>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={SEOModuleComponent} onEnter={(nextState, replace) => { replace({ pathName: 'getStarted' }); }} onChange={() => {}} />
<Route path="getStarted" component={GetStartedView} onChange={() => {}} />
</Route>
</Router>
</Provider>,
document.getElementById('app-container')
);
当我加载应用程序时 - 它会不断尝试重定向到'getStarted'
任何人都知道为什么会这样吗?
答案 0 :(得分:1)
为什么不使用WP Contacts组件?
<Router history={history}>
<Route path="/" component={App}>
<IndexRedirect to="/getStarted" />
<Route path="getStarted" component={GetStartedView} onChange={() => {}} />
</Route>
</Router>
答案 1 :(得分:0)
问题在于:
Othername
因为
(nextState, replace) => { replace({ pathName: 'getStarted' }); }
不是"pathName"
(小写) - react-router的历史模块的内部工作方式是默认重定向到当前路径的"pathname"
,从而创建循环。
此处打开了问题:https://github.com/ReactTraining/react-router/issues/4545