UNPKG

alinea

Version:
20 lines (18 loc) 684 B
import "../../chunks/chunk-NZLE2WMY.js"; // src/dashboard/util/KeepInView.tsx import { Loader } from "alinea/ui"; import { Suspense, useEffect, useRef } from "react"; import { Fragment, jsx } from "react/jsx-runtime"; function OnLoaded({ onLoad, children }) { useEffect(() => { onLoad(); }); return /* @__PURE__ */ jsx(Fragment, { children }); } function KeepInView({ children }) { const inView = useRef(null); return /* @__PURE__ */ jsx(Suspense, { fallback: inView.current ? inView.current : /* @__PURE__ */ jsx(Loader, { absolute: true }), children: /* @__PURE__ */ jsx(OnLoaded, { onLoad: () => inView.current = children, children }) }); } export { KeepInView };