Skip to content

Commit 5ebd44c

Browse files
committed
update category pill for react 18
1 parent 9888dcc commit 5ebd44c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/render/CategoryPill.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from "react";
22
import * as ReactDOM from "react-dom";
3+
import { createRoot, Root } from "react-dom/client";
34
import CategoryPillComponent, { CategoryPillState } from "../components/CategoryPillComponent";
45
import Config from "../config";
56
import { VoteResponse } from "../messageTypes";
@@ -10,6 +11,7 @@ import { Tooltip } from "./Tooltip";
1011
export class CategoryPill {
1112
container: HTMLElement;
1213
ref: React.RefObject<CategoryPillComponent>;
14+
root: Root;
1315

1416
unsavedState: CategoryPillState;
1517

@@ -38,10 +40,8 @@ export class CategoryPill {
3840
this.unsavedState = this.ref.current.state;
3941
}
4042

41-
ReactDOM.render(
42-
<CategoryPillComponent ref={this.ref} vote={vote} />,
43-
this.container
44-
);
43+
this.root = createRoot(this.container);
44+
this.root.render(<CategoryPillComponent ref={this.ref} vote={vote} />);
4545

4646
if (this.unsavedState) {
4747
this.ref.current?.setState(this.unsavedState);
@@ -64,7 +64,7 @@ export class CategoryPill {
6464
}
6565

6666
close(): void {
67-
ReactDOM.unmountComponentAtNode(this.container);
67+
this.root.unmount();
6868
this.container.remove();
6969
}
7070

0 commit comments

Comments
 (0)