one
Version:
One is a new React Framework that makes Vite serve both native and web.
23 lines (22 loc) • 743 B
JavaScript
import { useRef, forwardRef, useEffect } from "react";
import { jsx } from "react/jsx-runtime";
const NavigationContent = ({ render, children }) => render(children);
function useComponent(render) {
const renderRef = useRef(render);
return renderRef.current = render, useEffect(() => {
renderRef.current = null;
}), useRef(
forwardRef(({ children }, _ref) => {
const render2 = renderRef.current;
if (render2 === null)
throw new Error(
"The returned component must be rendered in the same render phase as the hook."
);
return /* @__PURE__ */ jsx(NavigationContent, { render: render2, children });
})
).current;
}
export {
useComponent
};
//# sourceMappingURL=useComponent.js.map