UNPKG

mcfe-react-lib

Version:

Mount/unmount React components flexibly with React 17 or 18 support

26 lines 701 B
// src/createInitial.tsx import React from "react"; var CreateInitial = (Component, adapter) => { const reactDomAdapter = adapter; let root = null; let container = null; return { _root: null, mount: function(selector) { container = document.querySelector(selector); if (!container) throw new Error("Mount target not found"); root = reactDomAdapter.render(/* @__PURE__ */ React.createElement(Component, null), container); this._root = root; }, unmount: function() { if (container) reactDomAdapter.unmount(container, root); this._root = null; } }; }; export { CreateInitial }; //# sourceMappingURL=createInitial.mjs.map