From 34ae853ed5727a7ffbdb344e57da1c2cc76e4fd2 Mon Sep 17 00:00:00 2001 From: Vasant Singh Negi Date: Sun, 18 Feb 2024 00:07:09 +0530 Subject: [PATCH] setLoading needs to split #46 -- resolved --- client/src/AppContainer.jsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/src/AppContainer.jsx b/client/src/AppContainer.jsx index ad10e76..9a41dee 100644 --- a/client/src/AppContainer.jsx +++ b/client/src/AppContainer.jsx @@ -9,13 +9,14 @@ import { Helmet } from "react-helmet"; import { useLocation } from "react-router-dom"; const ErrorComponent = ({ errorMessage }) => ( -
{errorMessage}
+
{errorMessage}
); const AppContainer = () => { const location = useLocation(); const [store, setStore] = useState(null); - const [loading, setLoading] = useState(true); + const [storeloading, setStoreloading] = useState(true); + const [serverStatus, setServerStatus] = useState(true); const [error, setError] = useState(null); useEffect(() => { @@ -25,7 +26,7 @@ const AppContainer = () => { } catch (err) { setError("Server is down. Please try again later."); } finally { - setLoading(false); + setServerStatus(false); } }; @@ -43,17 +44,21 @@ const AppContainer = () => { } catch (err) { setError(`Error initializing the app: ${err.message}`); } finally { - setLoading(false); + setStoreloading(false); } }; initializeStore(); }, []); - if (loading || error) { + if ((storeloading && serverStatus && !error) || error) { return ( -
- {loading ? : } +
+ {storeloading && serverStatus && !error ? ( + + ) : ( + + )}
); }