diff --git a/src/render/CategoryPill.tsx b/src/render/CategoryPill.tsx index 266796d1..af4f3f1b 100644 --- a/src/render/CategoryPill.tsx +++ b/src/render/CategoryPill.tsx @@ -1,5 +1,6 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; +import { createRoot, Root } from "react-dom/client"; import CategoryPillComponent, { CategoryPillState } from "../components/CategoryPillComponent"; import Config from "../config"; import { VoteResponse } from "../messageTypes"; @@ -10,6 +11,7 @@ import { Tooltip } from "./Tooltip"; export class CategoryPill { container: HTMLElement; ref: React.RefObject; + root: Root; unsavedState: CategoryPillState; @@ -38,10 +40,8 @@ export class CategoryPill { this.unsavedState = this.ref.current.state; } - ReactDOM.render( - , - this.container - ); + this.root = createRoot(this.container); + this.root.render(); if (this.unsavedState) { this.ref.current?.setState(this.unsavedState); @@ -64,7 +64,7 @@ export class CategoryPill { } close(): void { - ReactDOM.unmountComponentAtNode(this.container); + this.root.unmount(); this.container.remove(); }