Skip to content

Commit

Permalink
fix possible side effect
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Oct 26, 2022
1 parent 251a42e commit e09574a
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { ReactChild } from 'react';
import React, { createContext, useCallback, useContext, useMemo, useState } from 'react';
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';

import useObservable from 'react-use/lib/useObservable';
import { catchError, of, timeout } from 'rxjs';
Expand Down Expand Up @@ -81,12 +81,22 @@ export const RealTourContextProvider = ({ children }: { children: ReactChild })
// // guidedOnboardingApi.idkSetStepTo(stepId, 'active')
// }, []);

const [isMounted, setIsMounted] = useState(true);

useEffect(() => {
return () => {
setIsMounted(false);
};
}, []);

const endTourStep = useCallback(
async (stepId: SecurityStepId) => {
await guidedOnboardingApi?.completeGuideStep('security', stepId);
resetStep();
if (isMounted) {
resetStep();
}
},
[resetStep, guidedOnboardingApi]
[resetStep, guidedOnboardingApi, isMounted]
);

const context = {
Expand Down

0 comments on commit e09574a

Please sign in to comment.