0
votes

I'm writing web app with auth system. When logining, react-router succesfully redirects me from /login to /home(protected route). But when I'm clicking logout button it redirects me to /[object%20Object] instead of /login. What is the problem?

Logout button:

        <MenuItem
            onClick={() =>
                {
                history.push(`/login`);
                store.logout();
                handleMenuClose();
                }}>
            Log out
        </MenuItem>

Router:

          <BrowserRouter>
              {store.isAuth ? <ButtonAppBar /> : null}
              <Switch>
                  <Route path={LOGIN_ROUTE}>
                      {!store.isAuth ? <Login/> : <Redirect to={{pathname: HOME_ROUTE}}/>}
                  </Route>
                  <ProtectedRoute path={HOME_ROUTE} exact>
                      {store.isAuth ? <Home/> : <Redirect to={{pathname: LOGIN_ROUTE}}/>}
                  </ProtectedRoute>
                  <Route path={REGISTRATION_ROUTE}>
                      {!store.isAuth ? <Register/> : <Redirect to={{pathname: HOME_ROUTE}}/>}
                  </Route>
                  <Route>
                      <h1>404 Not Found</h1>
                  </Route>
              </Switch>
          </BrowserRouter>