Feat: If the interval between two outputs exceeds 600ms, a loading state is displayed at the end. (#16861)

### Summary

Feat: If the interval between two outputs exceeds 600ms, a loading state
is displayed at the end.
This commit is contained in:
balibabu
2026-07-13 18:02:29 +08:00
committed by GitHub
parent 8bc18154d2
commit 45862bf95d
7 changed files with 99 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
import { useEffect, useState } from 'react';
export function useLoadingPause(
loading: boolean,
content: string,
delay = 600,
) {
const [show, setShow] = useState(false);
useEffect(() => {
if (!loading || !content) {
setShow(false);
return;
}
const timer = setTimeout(() => {
setShow(true);
}, delay);
return () => clearTimeout(timer);
}, [loading, content, delay]);
return show;
}