const PATH = BASE + '/' + id;
<Route path="PATH" render={PageContainer} /> (DOESN'T WORK for the case below)
<Route path="PATH" component={PageContainer} /> (DOESN'T WORK for the case below)
<Route path="PATH" component={ () => <PageContainer /> } /> (WORKS)
Steps:
1) go to the page BASE/1
2) go back to BASE
3) go to BASE/2
PageContainer connects to the store and passes props to Page.
为什么第二种方法有效,而第一种方法不行?
Update: <Route path="PATH" render={PageContainer} /> (DOESN'T WORK for the case below)
最佳答案
尝试像这样访问它:
<Route path="PATH" component={PageContainer} />
组件和渲染 Prop 之间存在差异。您可以在这里找到答案: react router difference between component and render
关于reactjs - React Router 组件有功能和无功能的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54494261/