From d24abf6a2a711235e061c1cf7357de6c2c2affc4 Mon Sep 17 00:00:00 2001 From: Daniel D Orlando Date: Thu, 6 Apr 2023 15:42:39 -0700 Subject: [PATCH] Cleanup App.jsx --- client/src/App.jsx | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index b27a410bd3..1964a148bf 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -59,24 +59,18 @@ const App = () => { window.location.href = '/auth/login'; } - useEffect(() => { - if (searchEnabledQuery.error) { - console.error("Failed to get search enabled", searchEnabledQuery.error); - } - if (searchEnabledQuery.data) { - setIsSearchEnabled(searchEnabledQuery.data); - } - }, [searchEnabledQuery.data, setIsSearchEnabled, searchEnabledQuery.error]); - - useEffect(() => { - if (userQuery.error) { - console.error("Failed to get user", userQuery.error); - } - if (userQuery.data) { - setUser(userQuery.data); - } - }, [userQuery.data, setUser, userQuery.error]); + if (searchEnabledQuery.data) { + setIsSearchEnabled(searchEnabledQuery.data); + } else if(searchEnabledQuery.isError) { + console.error("Failed to get search enabled", searchEnabledQuery.error); + } + if (userQuery.data) { + setUser(userQuery.data); + } else if(userQuery.isError) { + console.error("Failed to get user", userQuery.error); + window.location.href = '/auth/login'; + } if (user) return (