From 9a1bf6bdf079de697c0cfd1a108c630227b30b40 Mon Sep 17 00:00:00 2001 From: Justin Staubach Date: Wed, 2 Oct 2019 19:46:40 -0400 Subject: [PATCH] Nav to start page on login When you log out and log in as a different page, the app should take the user to the start page not the last page viewed by the previous user. --- final/client/src/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/final/client/src/index.js b/final/client/src/index.js index 7e69da313..9a58e6c8f 100644 --- a/final/client/src/index.js +++ b/final/client/src/index.js @@ -6,6 +6,7 @@ import { InMemoryCache } from 'apollo-cache-inmemory'; import { HttpLink } from 'apollo-link-http'; import { ApolloProvider, useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; +import { navigate } from "@reach/router"; import Pages from './pages'; import Login from './pages/login'; @@ -54,7 +55,11 @@ const IS_LOGGED_IN = gql` function IsLoggedIn() { const { data } = useQuery(IS_LOGGED_IN); - return data.isLoggedIn ? : ; + if (data.isLoggedIn) { + return ; + } + navigate(`/`); + return ; } injectStyles();