UNPKG

@nexara/nativeflow

Version:

Beautiful, responsive, and customizable UI components for React Native – built for performance and seamless experiences.

33 lines (30 loc) 806 B
"use strict"; import { useContext, useId, useLayoutEffect } from "react"; import PortalContext from "./PortalContext.js"; const Portal = ({ children, name }) => { const { addComponent, removeComponent } = useContext(PortalContext); const uniqueId = name ?? useId(); // const uniqueId = useRef(name ?? `portal_${Math.random() * 50}`).current; // useEffect(() => { // return () => removeComponent(uniqueId); // }, []); // useEffect(() => { // addComponent({ name: uniqueId, component: children }); // }, [children]); useLayoutEffect(() => { addComponent({ name: uniqueId, component: children }); return () => removeComponent(uniqueId); }, [children, uniqueId]); return null; }; export default Portal; //# sourceMappingURL=Portal.js.map