diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 15eb73548..b9d91afa1 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -109,7 +109,6 @@ class AppContainer extends Component { }); try { - // See above for additional options, including other storage providers. await persistCache({ cache, storage: window.sessionStorage, diff --git a/client/src/App/App.js b/client/src/App/App.js index 3fa93e5d1..8ff98d835 100644 --- a/client/src/App/App.js +++ b/client/src/App/App.js @@ -1,4 +1,4 @@ -import React, { useEffect, Suspense, lazy } from "react"; +import React, { useEffect, Suspense, lazy, useState } from "react"; import { useApolloClient, useQuery } from "@apollo/react-hooks"; import { Switch, Route, Redirect } from "react-router-dom"; import firebase from "../firebase/firebase.utils"; @@ -26,11 +26,12 @@ const Unauthorized = lazy(() => export default () => { const apolloClient = useApolloClient(); - + const [loaded, setloaded] = useState(false); useEffect(() => { //Run the auth code only on the first render. const unsubscribeFromAuth = auth.onAuthStateChanged(async user => { - console.log("Auth State Changed.") + console.log("Auth State Changed."); + setloaded(true); if (user) { let token; token = await user.getIdToken(); @@ -87,16 +88,18 @@ export default () => { unsubscribeFromAuth(); }; }, [apolloClient]); - const HookCurrentUser = useQuery(GET_CURRENT_USER); + + if (!loaded) return ; if (HookCurrentUser.loading) return ; if (HookCurrentUser.error) return ; + return (
- TODO: Suspense Loading
}> + }>