反応ルーターを使用して、サーバー側の別のページからページをリダイレクトする必要があります。私が書いたコードはクライアント側で動作しますが、サーバー レンダーでは動作しません。ここでコードを見つけることができます:
これは/src/shared/components/LoginPage.js内のリダイレクト コードです。
componentWillMount() {
...
this.props.history.replaceState(null, '/home');
}
ノート:
https://github.com/jurgob/iso-login/blob/e26af0152896a949435db62549027b2683276db7/src/shared/routes.jsを見ると
やった:
function requireAuth(nextState, replaceState) {
// replaceState({ nextPathname: nextState.location.pathname }, '/login');
}
...
<Route path="home" component={HomePage} onEnter={requireAuth} />
このコードは機能していますが、コンポーネント内でリダイレクトを行いたい