reactjs - React Router 组件有功能和无功能的区别

标签 reactjs react-router containers connect

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/

相关文章:

image - Docker 创建镜像失败

javascript - 使用 React 渲染时如何访问现有的 dom 元素?

javascript - i18n 用于 react 组件的数组元素

reactjs - 如何使用高阶组件访问状态

javascript - 如果在索引路由 React JS 上则渲染内容

docker - 如何 'docker exec' 从头构建的容器?

reactjs - DataCloneError : The object could not be cloned. [火狐浏览器]

reactjs - React-Redux如何防止页面在重定向前渲染

javascript - 如何使用 React Router 将 div 放入 Switch 中?

azure应用程序服务,容器在一段时间后没有暴露的端口关闭