【发布时间】:2016-09-16 15:08:39
【问题描述】:
这是我的路线配置的简化版本。我正在使用反应路由器 2.4.0。现在,当我点击根“/”时,它会将我重定向到“父路由”:
<Redirect from="/" to="parent-route" />
<Route path="/" component={App}>
<Route path="parent-route" >
<IndexRoute component={SomeComponent1} />
<Route path="child-route-1/:entityId" component={SomeComponent2} />
<Route path="child-route-2/:entityId" component={SomeComponent3} />
</Route>
</Route>
但我想更改 Redirect 的行为以重定向到具有具体 Id 集的子路由。更准确地说,我想做这样的事情
<Redirect from="/" to="parent-route/child-route-1/[firstAvailableEntityId]" />
我有 redux-store 中所有可用实体的列表。有谁知道如何将Redirect 与Redux-Store 结合起来生成动态重定向网址?
我尝试包装Redirect 组件并将其连接到商店。但这不起作用,因为Redirect 的渲染方法永远不会被调用。
【问题讨论】:
标签: reactjs react-router redux