Skip to content

Commit f63659b

Browse files
authored
fix: suspense repeat trigger (#58)
1 parent e4bd175 commit f63659b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/hooks/useStatus.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,17 @@ export default function useStatus(
191191
activeRef.current = active;
192192

193193
// ============================ Status ============================
194+
const visibleRef = useRef<boolean | null>(null);
195+
194196
// Update with new status
195197
useIsomorphicLayoutEffect(() => {
198+
// When use Suspense, the `visible` will repeat trigger,
199+
// But not real change of the `visible`, we need to skip it.
200+
// https://github.com/ant-design/ant-design/issues/44379
201+
if (mountedRef.current && visibleRef.current === visible) {
202+
return;
203+
}
204+
196205
setAsyncVisible(visible);
197206

198207
const isMounted = mountedRef.current;
@@ -232,6 +241,8 @@ export default function useStatus(
232241
// Set back in case no motion but prev status has prepare step
233242
setStatus(STATUS_NONE);
234243
}
244+
245+
visibleRef.current = visible;
235246
}, [visible]);
236247

237248
// ============================ Effect ============================

0 commit comments

Comments
 (0)