mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
update category pill for react 18
This commit is contained in:
parent
9888dcc323
commit
5ebd44c0c7
1 changed files with 5 additions and 5 deletions
|
@ -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<CategoryPillComponent>;
|
||||
root: Root;
|
||||
|
||||
unsavedState: CategoryPillState;
|
||||
|
||||
|
@ -38,10 +40,8 @@ export class CategoryPill {
|
|||
this.unsavedState = this.ref.current.state;
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<CategoryPillComponent ref={this.ref} vote={vote} />,
|
||||
this.container
|
||||
);
|
||||
this.root = createRoot(this.container);
|
||||
this.root.render(<CategoryPillComponent ref={this.ref} vote={vote} />);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue