2
私はredux-auth-wrapperを使用して、保護されたルートの認証ロジックを処理しています。しかし、リダイレクトしていません。状態のredux-auth-wrapperリダイレクトが動作しない
私の「ユーザー」オブジェクト形状である:ここでは
// state.auth
{
isAuthenticated: true,
isLoading: false,
loadError: null
}
は私routes/index.js
ファイル
const authenticated = UserAuthWrapper({
authSelector: state => state.auth,
predicate: authData => authData.isAuthenticated,
redirectAction: routerActions.replace,
// redirects to /login by default
})
export default (
<Route path="/" component={App}>
<IndexRoute component={authenticated(Secret)} />
<Route path="/login" component={Login} />
<Route path="/item_1" component={Item1} />
<Route path="/item_2" component={Item2}>
<Route path="/nested_item_2/:id" component={NestedItem2} />
</Route>
</Route>
)
、私IndexRoute
が保護コンポーネントであるので、私はlocalhost:3000
に行くときです私はそれを/login
にリダイレクトすることを期待していますが、何も起こりません。ヌルボディのSecret
コンポーネントにとどまります。
Yep!それが私のしたことです。私が投稿したはずの答えを提供してくれてありがとう – Carpetfizz