From c09006937e6163099d6c63c15c75e751ace53475 Mon Sep 17 00:00:00 2001 From: Kevin Tun Date: Thu, 8 Feb 2024 01:40:53 -0600 Subject: [PATCH] refactor(useAuthorization.ts): remove unnecessary setLoading state variable and setLoading calls The setLoading state variable and its corresponding calls to setLoading(false) are no longer necessary as they are not being used. Removing them simplifies the code and improves readability. --- packages/auth/src/useAuthorization.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/auth/src/useAuthorization.ts b/packages/auth/src/useAuthorization.ts index 7ae8eb93ac..1b8b09ee03 100644 --- a/packages/auth/src/useAuthorization.ts +++ b/packages/auth/src/useAuthorization.ts @@ -11,18 +11,17 @@ type useAuthorizationProperties = { entries: Array } */ const useAuthorization = ({ entries }: useAuthorizationProperties) => { // Fetch the user information using the useLogto hook - const { fetchUserInfo, isAuthenticated } = useLogto() + const { fetchUserInfo, isAuthenticated, isLoading } = useLogto() // Initialize state variables const [isAuthorized, setAuthorization] = useState(false) - const [isLoading, setLoading] = useState(true) + // const [isLoading, setLoading] = useState(true) const [user, setUser] = useState() - useEffect(() => { // Function to check user authorization const authCheck = async (records: Array) => { if (!isAuthenticated) { - setLoading(false) + // setLoading(false) return } // Fetch the user information and cast it to UserWithRoles type @@ -33,7 +32,7 @@ const useAuthorization = ({ entries }: useAuthorizationProperties) => { setUser(authUser) } // Set the loading state to false once the authorization check is completed - setLoading(false) + // setLoading(false) } // Perform the authorization check when the entries array changes authCheck(entries)