找不到路由器设置页面在React Router 4中不起作用

时间:2019-03-17 04:43:48

标签: reactjs react-router react-router-v4 react-router-dom

反应路由器设置如下。它根本没有路由到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>
)};

0 个答案:

没有答案