Files
ragflow/web/src/hooks/use-loading-pause.ts
balibabu 45862bf95d 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.
2026-07-13 18:02:29 +08:00

25 lines
439 B
TypeScript

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;
}