【发布时间】:2019-07-13 23:20:39
【问题描述】:
我正在使用这个包https://github.com/SimpleContacts/react-router-async-routes
<Route
async
path={`${match.url}app`}
render={async () => {
try {
Promise.all([await Axios.get('/api/loggedin')]).then((userData) => {
this.props.setUser(userData[0].data);
});
return <MainApp />
} catch (err) {
return <Redirect to={{ pathname: '/login', state: { from: this.props.location } }} />
}
}}
/> //history.push not working on this one.
<Route path={`${match.url}somepage`} component={SomeComp} /> // history.push works
当我使用 React Router 的 history.push 到自定义异步路由 /app 时,url 发生变化,redux 路由发生变化,但未加载 App-component。它正在一条“正常”的路线上工作。
我无法确定问题出在哪里。
有什么想法吗?
【问题讨论】:
-
你有嵌套
BrowserRouter吗?我有类似的问题..
标签: reactjs react-router