From 9ff5c09e671c4f07f25f30a60617fca7660e7607 Mon Sep 17 00:00:00 2001 From: CRIMX Date: Fri, 29 Jan 2021 19:56:20 +0800 Subject: [PATCH] fix: useUnmountPromise stops on immediate update --- src/useUnmountPromise.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; });