UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

35 lines (32 loc) • 927 B
import { useCallback, useState } from "react"; import { DomView } from "../web/DomView.mjs"; import { ReservedRegionsContext } from "./reservedRegionsContext.mjs"; import { jsx } from "react/jsx-runtime"; function Provider({ children, onLayout, ...props }) { const [snapshot, setSnapshot] = useState({ regions: [], ready: true, bounds: null }); const onProviderLayout = useCallback((event) => { onLayout?.(event); const { width, height } = event.nativeEvent.layout; setSnapshot((current) => current.bounds?.width === width && current.bounds.height === height ? current : { ...current, bounds: { width, height } }); }, [onLayout]); return /* @__PURE__ */ jsx(ReservedRegionsContext.Provider, { value: snapshot, children: /* @__PURE__ */ jsx(DomView, { ...props, onLayout: onProviderLayout, children }) }); } export { Provider }; //# sourceMappingURL=ReservedRegions.mjs.map