From 0eda5772775ef82825c7f32c73aefb76f902b222 Mon Sep 17 00:00:00 2001 From: Sai Venkat Desu Date: Fri, 2 Aug 2024 10:44:21 +0530 Subject: [PATCH] chore: changed to useMemo for auth0 instance of combining useState & useEffect --- src/hooks/auth0-provider.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/hooks/auth0-provider.tsx b/src/hooks/auth0-provider.tsx index e848632e..534a571d 100644 --- a/src/hooks/auth0-provider.tsx +++ b/src/hooks/auth0-provider.tsx @@ -73,11 +73,10 @@ const Auth0Provider = ({ clientId, children, }: PropsWithChildren<{ domain: string; clientId: string }>) => { - const [client, setClient] = useState(() => new Auth0({ domain, clientId })); - - useEffect(() => { - setClient(new Auth0({ domain, clientId })); - }, [domain, clientId]); + const client = useMemo( + () => new Auth0({ domain, clientId }), + [domain, clientId] + ); const [state, dispatch] = useReducer(reducer, initialState); useEffect(() => {