Skip to content

Commit

Permalink
fix: suspense repeat trigger (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Dec 19, 2024
1 parent e4bd175 commit f63659b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hooks/useStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,17 @@ export default function useStatus(
activeRef.current = active;

// ============================ Status ============================
const visibleRef = useRef<boolean | null>(null);

// Update with new status
useIsomorphicLayoutEffect(() => {
// When use Suspense, the `visible` will repeat trigger,
// But not real change of the `visible`, we need to skip it.
// https://github.com/ant-design/ant-design/issues/44379
if (mountedRef.current && visibleRef.current === visible) {
return;
}

setAsyncVisible(visible);

const isMounted = mountedRef.current;
Expand Down Expand Up @@ -232,6 +241,8 @@ export default function useStatus(
// Set back in case no motion but prev status has prepare step
setStatus(STATUS_NONE);
}

visibleRef.current = visible;
}, [visible]);

// ============================ Effect ============================
Expand Down

0 comments on commit f63659b

Please sign in to comment.