【发布时间】:2018-05-01 15:37:00
【问题描述】:
我是 redux 的新手,我创建了一个导航到用户编辑页面的路由,我还想使用下面的代码将 store 和 history 作为 props 传递。
<Route path="/edit/:id" render={({history}) => (
<EditUser store={store} history={history} />
)}/>
但现在我无法访问我在 EditUser 组件中传递的参数 (:id)。当我尝试使用 this.props.match.params.id 访问时,它显示未定义,但如果我重写我的路由到
就可以了<Route path="/edit/:id" component={EditUser}/>
但现在我认为我无法通过其他道具。
非常感谢您的帮助。
【问题讨论】:
-
你在使用哪个
<Route><BrowserRouter>,分享你的index.js? -
是的,我在 index.js 中使用
标签: reactjs react-router react-router-v4 react-props