Skip to content

Commit 83ea183

Browse files
authored
Merge pull request #1517 from mchangrh/react-18
React 18
2 parents 5c9e064 + 81e85c1 commit 83ea183

17 files changed

+112
-96
lines changed

package-lock.json

Lines changed: 46 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"description": "",
55
"main": "background.js",
66
"dependencies": {
7-
"react": "^17.0.2",
8-
"react-dom": "^17.0.2"
7+
"react": "^18.2.0",
8+
"react-dom": "^18.2.0"
99
},
1010
"devDependencies": {
1111
"@types/chrome": "^0.0.197",
1212
"@types/firefox-webext-browser": "^94.0.1",
1313
"@types/jest": "^29.1.2",
14-
"@types/react": "^17.0.47",
15-
"@types/react-dom": "^17.0.17",
14+
"@types/react": "^18.0.21",
15+
"@types/react-dom": "^18.0.6",
1616
"@types/selenium-webdriver": "^4.1.5",
1717
"@types/wicg-mediasession": "^1.1.4",
1818
"@typescript-eslint/eslint-plugin": "^5.39.0",

src/components/NoticeComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export interface NoticeProps {
3636
zIndex?: number,
3737
style?: React.CSSProperties
3838
biggerCloseButton?: boolean;
39+
children?: React.ReactNode
3940
}
4041

4142
export interface NoticeState {

src/components/NoticeTextSectionComponent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export interface NoticeTextSelectionProps {
44
icon?: string,
55
text: string,
66
idSuffix: string,
7-
onClick?: (event: React.MouseEvent) => unknown
7+
onClick?: (event: React.MouseEvent) => unknown,
8+
children?: React.ReactNode
89
}
910

1011
export interface NoticeTextSelectionState {

src/components/SponsorTimeEditComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface SponsorTimeEditProps {
2323
submissionNotice: SubmissionNoticeComponent;
2424
categoryList?: Category[];
2525
categoryChangeListener?: (index: number, category: Category) => void;
26+
children?: React.ReactNode;
2627
}
2728

2829
export interface SponsorTimeEditState {

src/components/options/CategorySkipOptionsComponent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface CategorySkipOptionsProps {
1313
category: Category;
1414
defaultColor?: string;
1515
defaultPreviewColor?: string;
16+
children?: React.ReactNode;
1617
}
1718

1819
export interface CategorySkipOptionsState {

src/components/options/KeybindComponent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import * as ReactDOM from "react-dom";
2+
import { createRoot, Root } from 'react-dom/client';
33
import Config from "../../config";
44
import { Keybind } from "../../types";
55
import KeybindDialogComponent from "./KeybindDialogComponent";
@@ -14,6 +14,7 @@ export interface KeybindState {
1414
}
1515

1616
let dialog;
17+
let root: Root;
1718

1819
class KeybindComponent extends React.Component<KeybindProps, KeybindState> {
1920
constructor(props: KeybindProps) {
@@ -56,11 +57,12 @@ class KeybindComponent extends React.Component<KeybindProps, KeybindState> {
5657
dialog = parent.document.createElement("div");
5758
dialog.id = "keybind-dialog";
5859
parent.document.body.prepend(dialog);
59-
ReactDOM.render(<KeybindDialogComponent option={this.props.option} closeListener={(updateWith) => this.closeEditDialog(updateWith)} />, dialog);
60+
root = createRoot(dialog);
61+
root.render(<KeybindDialogComponent option={this.props.option} closeListener={(updateWith) => this.closeEditDialog(updateWith)} />);
6062
}
6163

6264
closeEditDialog(updateWith: Keybind): void {
63-
ReactDOM.unmountComponentAtNode(dialog);
65+
root.unmount();
6466
dialog.remove();
6567
if (updateWith != null)
6668
this.setState({keybind: updateWith});

src/components/options/UnsubmittedVideoListItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { exportTimes, exportTimesAsHashParam } from "../../utils/exporter";
55

66
export interface UnsubmittedVideosListItemProps {
77
videoID: string;
8+
children?: React.ReactNode;
89
}
910

1011
export interface UnsubmittedVideosListItemState {

src/options.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import * as ReactDOM from "react-dom";
2+
import { createRoot } from 'react-dom/client';
33

44
import Config from "./config";
55
import * as CompileConfig from "../config.json";
@@ -258,7 +258,8 @@ async function init() {
258258
break;
259259
}
260260
case "keybind-change": {
261-
ReactDOM.render(React.createElement(KeybindComponent, {option: option}), optionsElements[i].querySelector("div"));
261+
const root = createRoot(optionsElements[i].querySelector("div"));
262+
root.render(React.createElement(KeybindComponent, {option: option}));
262263
break;
263264
}
264265
case "display": {

src/render/CategoryChooser.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from "react";
2-
import * as ReactDOM from "react-dom";
2+
import { createRoot } from 'react-dom/client';
3+
34
import CategoryChooserComponent from "../components/options/CategoryChooserComponent";
45

56
class CategoryChooser {
@@ -9,9 +10,9 @@ class CategoryChooser {
910
constructor(element: Element) {
1011
this.ref = React.createRef();
1112

12-
ReactDOM.render(
13-
<CategoryChooserComponent ref={this.ref} />,
14-
element
13+
const root = createRoot(element);
14+
root.render(
15+
<CategoryChooserComponent ref={this.ref} />
1516
);
1617
}
1718

0 commit comments

Comments
 (0)