Skip to content

Commit

Permalink
chore: changed to useMemo for auth0 instance of combining useState & …
Browse files Browse the repository at this point in the history
…useEffect
  • Loading branch information
desusai7 committed Aug 2, 2024
1 parent dfd42cd commit 0eda577
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/hooks/auth0-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down

0 comments on commit 0eda577

Please sign in to comment.