MCPcopy
hub / github.com/msgbyte/tianji / DelayRender

Function DelayRender

src/client/components/DelayRender.tsx:11–28  ·  view source on GitHub ↗
({
  children,
  delay = 500,
})

Source from the content-addressed store, hash-verified

9}
10
11export const DelayRender: React.FC<DelayRenderProps> = ({
12 children,
13 delay = 500,
14}) => {
15 const [shouldRender, setShouldRender] = useState(false);
16
17 useEffect(() => {
18 const timer = window.setTimeout(() => {
19 setShouldRender(true);
20 }, delay);
21
22 return () => {
23 window.clearTimeout(timer);
24 };
25 }, [delay]);
26
27 return shouldRender ? <>{children}</> : null;
28};

Callers

nothing calls this directly

Calls 2

setTimeoutMethod · 0.80
clearTimeoutMethod · 0.80

Tested by

no test coverage detected