import { Root, createRoot } from "react-dom/client"; import QuizSideButton from "./QuizSideButton"; import { ComponentPropsWithoutRef } from "react"; export class SideWidget { root: Root | undefined; element = document.createElement("div"); constructor({ quizId, position }: ComponentPropsWithoutRef) { this.element.style.setProperty("display", "none"); document.body.appendChild(this.element); this.root = createRoot(this.element); this.root.render( ); } destroy() { if (this.root) this.root.unmount(); this.element.remove(); } }