Skip to content

Commit

Permalink
fix: suspense repeat trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 19, 2024
1 parent e4bd175 commit 4506204
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;

Check warning on line 202 in src/hooks/useStatus.ts

View check run for this annotation

Codecov / codecov/patch

src/hooks/useStatus.ts#L202

Added line #L202 was not covered by tests
}

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 4506204

Please sign in to comment.