反应路由器设置如下。它根本没有路由到UnAuthorizedNotFound页面。我不知道下面的代码有什么问题。成功登录后,我使用cookie进行设置。 任何建议表示赞赏。
const Layouts = (props) => {
const userCookie = props.cookies.get('user');
return (
<Switch>
<Route
exact
path="/"
render={() => (<Login cookies={props.cookies}/>)}
/>
<Route
path="/login"
render={() => (<Login cookies={props.cookies}/>)}
/>
<Route
path="/register"
render={() => (<Register cookies={props.cookies}/>)}
/>
<Route
path="/forgotpassword"
render={() => (<ForgotPassword cookies={props.cookies}/>)}
/>
{
userCookie
&& (
<div>
<Route
path="/dashboard"
render={() => (<Dashboard cookies={props.cookies}/>)}
/>
<Route
path="/advertisement"
render={() => (<AdvertisementWrapper cookies={props.cookies}/>)}
/>
<Route
path="/settings"
render={() => (<SettingsWrapper cookies={props.cookies}/>)}
/>
</div>
)
}
<Route
render={() => (<UnAuthorizedNotFound cookies={props.cookies}/>)}
/>
</Switch>
)};