Skip to content

Commit 09cb246

Browse files
authored
Bump react to v18, and highlight.js to v11 (#327)
1 parent 6ba58bd commit 09cb246

File tree

5 files changed

+73
-96
lines changed

5 files changed

+73
-96
lines changed

package-lock.json

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

package.json

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"@babel/preset-env": "^7.12.11",
2626
"@babel/preset-react": "^7.12.10",
2727
"@types/lodash": "^4.17.18",
28-
"@types/react": "^17.0.2",
29-
"@types/react-dom": "^17.0.2",
28+
"@types/react": "^18.3.1",
29+
"@types/react-dom": "^18.3.1",
3030
"@types/react-helmet": "^6.1.11",
3131
"@types/react-router-dom": "^5.3.3",
3232
"@typescript-eslint/parser": "^8.34.1",
@@ -52,12 +52,12 @@
5252
"d3-scale": "^3.2.3",
5353
"d3-scale-chromatic": "^1.3.3",
5454
"d3-shape": "^2.0.0",
55-
"highlight.js": "~9.8.0",
55+
"highlight.js": "^11.11.1",
5656
"lodash": "^4.17.20",
5757
"monaco-editor": "^0.52.2",
5858
"prop-types": "^15.8.1",
59-
"react": "^17.0.2",
60-
"react-dom": "^17.0.2",
59+
"react": "^18.3.1",
60+
"react-dom": "^18.3.1",
6161
"react-helmet": "^6.1.0",
6262
"react-monaco-editor": "^0.58.0",
6363
"react-router": "^4.3.1",
@@ -68,17 +68,5 @@
6868
"scroll-behavior": "^0.9.12",
6969
"simple-line-icons": "^2.5.5"
7070
},
71-
"license": "MIT",
72-
"overrides": {
73-
"@reduxjs/toolkit": {
74-
".": "^1.9.7",
75-
"dependencies": {
76-
"react": "17.0.1"
77-
}
78-
},
79-
"react-redux": {
80-
".": "^8.1.3",
81-
"react": "17.0.1"
82-
}
83-
}
71+
"license": "MIT"
8472
}

src/app.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable import/no-unresolved */
2-
import ReactDOM from 'react-dom';
2+
import { createRoot } from 'react-dom/client';
33
import { loader } from '@monaco-editor/react';
44
import * as monaco from 'monaco-editor';
55
// @ts-ignore
@@ -37,4 +37,9 @@ loader.config({ monaco });
3737

3838
loader.init().then(/* ... */);
3939

40-
ReactDOM.render(<Root />, document.getElementById('app'));
40+
const container = document.getElementById('app');
41+
if (container == null) {
42+
throw new Error('Container element with id "app" not found');
43+
}
44+
const root = createRoot(container);
45+
root.render(<Root />);

src/layouts/Frame.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from 'react';
1+
import { Component, ReactNode } from 'react';
22
import { Link } from 'react-router-dom';
33
import { RouteComponentProps, withRouter } from 'react-router';
44
import Helmet from 'react-helmet';
@@ -12,7 +12,9 @@ const locales = [
1212
{ locale: 'zh-CN', text: '中文' },
1313
];
1414

15-
type FrameProps = RouteComponentProps;
15+
type FrameProps = RouteComponentProps & {
16+
children: ReactNode;
17+
};
1618

1719
class Frame extends Component<FrameProps> {
1820
renderLocaleSwitch(curLocale: string) {

src/utils/Highlight.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { PureComponent } from 'react';
1+
import React, { PureComponent, ReactNode } from 'react';
22
// @ts-ignore
33
import hljs from 'highlight.js';
44

55
type HighlightProps = {
66
className?: string;
7+
children: ReactNode;
78
};
89

910
class Highlight extends PureComponent<HighlightProps> {
@@ -26,7 +27,7 @@ class Highlight extends PureComponent<HighlightProps> {
2627
if (domNode == null) {
2728
return;
2829
}
29-
const nodes = domNode.querySelectorAll('pre code');
30+
const nodes: NodeListOf<HTMLElement> = domNode.querySelectorAll('pre code');
3031

3132
if (nodes.length > 0) {
3233
for (let i = 0; i < nodes.length; i++) {

0 commit comments

Comments
 (0)