点击切换路由时验证登陆

【点击切换路由时验证登陆】onEnter钩子还可以用来做认证。
const requireAuth = (nextState, replace) => {
if (!auth.isAdmin()) {
// Redirect to Home page if not an Admin
replace({ pathname: '/' })
}
}
export const AdminRoutes = () => {
return (

)
}

    推荐阅读