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
組件上。
是的!這就是我所做的。感謝您提供我應該發佈的答案 – Carpetfizz