React Router 将 IndexRoute 重定向到正确的路径

React Router redirect IndexRoute to proper path

我正在尝试配置 React Router,以便在访问 http://url/manage/roomId 时直接转到 http://url/manage/roomId/sessions(加载 RoomSessions 组件)。这些是选项卡组件的路由,我想默认加载第一个选项卡的内容(它确实如此)并使用正确的 URL(它没有)。

除了重定向,它工作正常

<Route
    path="manage/:roomId"
    component={RoomsManagerManageRoom}
    onEnter={requireAuth}
>
    <IndexRoute component={RoomSessions} onEnter={requireAuth} />
    <Route path="sessions" component={RoomSessions} onEnter={requireAuth} />
    <Route path="meetings" component={RoomMeetings} onEnter={requireAuth} />
    <Route path="files" component={RoomFiles} onEnter={requireAuth} />
    <Route path="recordings" component={RoomRecordings} onEnter={requireAuth} />
    <Route path="sections" component={RoomSections} onEnter={requireAuth} />
    <Route path="hosts" component={RoomHosts} onEnter={requireAuth} />
</Route>

我错过了什么?

<IndexRoute /> 行替换为

<IndexRedirect to="sessions" />