chatbot-template/lib/editor/react-renderer.tsx

14 lines
342 B
TypeScript
Raw Normal View History

import { createRoot } from "react-dom/client";
2024-10-30 16:01:24 +05:30
// biome-ignore lint/complexity/noStaticOnlyClass: "Needs to be static"
2024-10-30 16:01:24 +05:30
export class ReactRenderer {
static render(component: React.ReactElement, dom: HTMLElement) {
const root = createRoot(dom);
root.render(component);
2024-11-01 14:13:17 +05:30
2024-10-30 16:01:24 +05:30
return {
destroy: () => root.unmount(),
};
}
}