mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
24 lines
450 B
TypeScript
24 lines
450 B
TypeScript
import { useState, useEffect } from "react";
|
|
|
|
type Props = {
|
|
delay?: number;
|
|
children: JSX.Element;
|
|
};
|
|
|
|
export default function DelayedMount({ delay = 250, children }: Props) {
|
|
const [isShowing, setShowing] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const timeout = setTimeout(() => setShowing(true), delay);
|
|
return () => {
|
|
clearTimeout(timeout);
|
|
};
|
|
}, [delay]);
|
|
|
|
if (!isShowing) {
|
|
return null;
|
|
}
|
|
|
|
return children;
|
|
}
|