Skip to content

Commit

Permalink
update handleRedirect hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tnorling committed Oct 20, 2020
1 parent 3885422 commit 0617b5c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/msal-react/src/useHandleRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import { useMsal } from "./MsalProvider";

export function useHandleRedirect(): [AuthenticationResult|null, AuthError|null] {
const { instance } = useMsal();
const [
[redirectResponse, redirectError],
setRedirectResponse,
] = useState<[AuthenticationResult|null, AuthError|null]>([null, null]);
const [response, setResponse] = useState<AuthenticationResult|null>(null);
const [error, setError] = useState<AuthError|null>(null);

useEffect(() => {
instance.handleRedirectPromise().then(response => {
if (response) {
setRedirectResponse([response, null]);
setResponse(response);
setError(null);
}
}).catch(e => {
setRedirectResponse([null, e]);
setError(e);
setResponse(null);
});
}, [instance]);

return [redirectResponse, redirectError];
return [response, error];
}

0 comments on commit 0617b5c

Please sign in to comment.