0
<Route path="/projects" component={ProjectsLayout}>
<IndexRoute component={Projects} />
<Route path=":id">
<IndexRoute component={Contents} />
<Route path="files/:fileId" component={FileViewer} />
<Route path="folders/**/:folderId" component={Folder} />
</Route>
</Route>
私がやりたいことは、彼らがにナビゲートする前にルートを「保存」でありますProjectsLayout
、前のコンポーネントに戻ることができます。方法はあり
state = { index: 1 }; // index is one so it goes one more than the layout
componentDidMount() {
this.props.router.listen(this.onRouteChange);
}
onClickExit =() => this.props.router.goBack(this.state.index);
しかし、私はインデックス
を維持するための効率的な方法を見つけることができません。
私の計画はすなわち、パスを監視し、その多くずつ戻っていますreact-router
でこれを行うには?
反応し、ルータに役立ちます願っていますいくつかのドキュメントでこれを見て覚えていないことを謝罪[履歴] (https://github.com/ReactTraining/react-router/blob/master/docs/guides/Histories.md)はすでにこれを追跡しています。 –