Skip to content

Commit

Permalink
Use initializer function for mfaCtx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Jan 8, 2025
1 parent acdc2f8 commit ebade41
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/packages/teleport/src/MFAContext/MFAContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ export const MfaContextProvider = ({ children }: PropsWithChildren) => {
[adminMfa]
);

const [mfaCtx, setMfaCtx] = useState<MfaContextValue>();

if (!mfaCtx) {
const [mfaCtx] = useState<MfaContextValue>(() => {
const mfaCtx = { getMfaChallengeResponse };
setMfaCtx(mfaCtx);
auth.setMfaContext(mfaCtx);
api.setMfaContext(mfaCtx);
}
return mfaCtx;
});

return (
<MfaContext.Provider value={mfaCtx}>
Expand Down

0 comments on commit ebade41

Please sign in to comment.