import { useEffect, useState } from "react"; import { Platform_iOS } from "../commons"; export type LazyProps = { enableiOS?: boolean; lazyTime?: number; children?: any; }; export const Lazy = (props: LazyProps) => { const { enableiOS, lazyTime = 1000, children } = props; const [show, setShow] = useState(Platform_iOS && !enableiOS); useEffect(() => { const timeout = !Platform_iOS || enableiOS ? setTimeout(() => { setShow(true); }, lazyTime) : 0; return () => { timeout && clearTimeout(timeout); }; }, []); return show ? children : null; };