Skip to content

Commit

Permalink
fix: useUnmountPromise stops on immediate update
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx authored Jan 29, 2021
1 parent 5425ba9 commit 9ff5c09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/useUnmountPromise.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useMemo, useRef, useEffect } from 'react';
import { useMemo, useRef } from 'react';
import useEffectOnce from './useEffectOnce';

export type Race = <P extends Promise<any>, E = any>(promise: P, onError?: (error: E) => void) => P;

const useUnmountPromise = (): Race => {
const refUnmounted = useRef(false);
useEffect(() => () => {
useEffectOnce(() => () => {
refUnmounted.current = true;
});

Expand Down

0 comments on commit 9ff5c09

Please sign in to comment.