diff --git a/src/useUnmountPromise.ts b/src/useUnmountPromise.ts index cb561a2dbe..7a2f09654c 100644 --- a/src/useUnmountPromise.ts +++ b/src/useUnmountPromise.ts @@ -1,10 +1,11 @@ -import { useMemo, useRef, useEffect } from 'react'; +import { useMemo, useRef } from 'react'; +import useEffectOnce from './useEffectOnce'; export type Race =
, E = any>(promise: P, onError?: (error: E) => void) => P; const useUnmountPromise = (): Race => { const refUnmounted = useRef(false); - useEffect(() => () => { + useEffectOnce(() => () => { refUnmounted.current = true; });