Skip to content

Commit 7b80ce0

Browse files
authored
upgrade to react18 (#323)
* upgrade to react18 * fix * remove .pause() * fix login test * log generate test * upgrade react inspector * upgrade package lock * fix react-inspector * fix
1 parent 02f5261 commit 7b80ce0

File tree

24 files changed

+342
-340
lines changed

24 files changed

+342
-340
lines changed

package-lock.json

Lines changed: 261 additions & 273 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"devDependencies": {
55
"lerna": "^5.0.0",
66
"playwright": "^1.18.1",
7-
"patch-package": "^6.4.7"
7+
"patch-package": "^6.4.7",
8+
"@types/react": "^18.0.25",
9+
"@types/react-dom": "^18.0.9"
810
},
911
"workspaces": [
1012
"packages/*"
@@ -35,6 +37,8 @@
3537
},
3638
"overrides": {
3739
"--comment": "needed so that playwright-test doesn't install a different version of pw",
38-
"playwright-core": "1.24.2"
40+
"playwright-core": "1.24.2",
41+
"@types/react": "^18.0.25",
42+
"@types/react-dom": "^18.0.9"
3943
}
4044
}

packages/editor/package.json

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"dependencies": {
66
"@atlaskit/atlassian-navigation": "^2.2.6",
7-
"@atlaskit/avatar": "^21.0.0",
7+
"@atlaskit/avatar": "^21.1.1",
88
"@atlaskit/banner": "^11.6.1",
9-
"@atlaskit/breadcrumbs": "^11.6.2",
9+
"@atlaskit/breadcrumbs": "^11.7.3",
1010
"@atlaskit/button": "^16.3.5",
1111
"@atlaskit/checkbox": "^12.3.18",
1212
"@atlaskit/comment": "^10.5.2",
@@ -23,7 +23,7 @@
2323
"@atlaskit/progress-bar": "^0.5.8",
2424
"@atlaskit/section-message": "^6.1.14",
2525
"@atlaskit/spinner": "^15.1.14",
26-
"@atlaskit/select": "^15.6.0",
26+
"@atlaskit/select": "^15.7.5",
2727
"@atlaskit/textarea": "^4.3.8",
2828
"@atlaskit/textfield": "^5.1.12",
2929
"@atlaskit/tree": "^8.6.1",
@@ -42,11 +42,6 @@
4242
"@typecell-org/parsers": "^0.0.3",
4343
"@typecell-org/common": "^0.0.3",
4444
"@typecell-org/engine": "^0.0.3",
45-
"@types/markdown-it": "^10.0.3",
46-
"@types/node": "^16.0.0",
47-
"@types/react": "^17.0.0",
48-
"@types/react-dom": "^17.0.0",
49-
"@types/uuid": "^8.3.0",
5045
"@typescript/vfs": "^1.3.4",
5146
"@blocknote/core": "^0.1.0",
5247
"classnames": "^2.3.1",
@@ -66,15 +61,15 @@
6661
"prettier": "2.4.1",
6762
"probe.gl": "^3.1.4",
6863
"qs": "^6.10.1",
69-
"react": "^17.0.2",
64+
"react": "^18.2.0",
7065
"react-avatar": "^3.10.0",
7166
"react-dnd": "^14.0.2",
7267
"react-dnd-html5-backend": "^14.0.0",
73-
"react-dom": "^17.0.2",
68+
"react-dom": "^18.2.0",
7469
"react-error-overlay": "^6.0.9",
7570
"react-github-btn": "^1.2.1",
76-
"react-icons": "^4.2.0",
77-
"react-inspector": "^5.1.0",
71+
"react-icons": "^4.6.0",
72+
"react-inspector": "^6.0.1",
7873
"react-intl-next": "npm:react-intl@^5.18.1",
7974
"remixicon-react": "^1.0.0",
8075
"semver": "^7.3.5",
@@ -147,13 +142,16 @@
147142
"@types/lodash": "^4.14.168",
148143
"@types/lowlight": "0.0.2",
149144
"@types/qs": "^6.9.7",
150-
"@types/react-inspector": "^4.0.1",
151145
"@types/semver": "^7.3.8",
152146
"@types/speakingurl": "^13.0.2",
153147
"@types/ua-parser-js": "^0.7.36",
154148
"@types/uuid": "^8.3.0",
155149
"@types/zxcvbn": "^4.4.1",
156150
"@types/prettier": "^2.6.4",
151+
"@types/markdown-it": "^10.0.3",
152+
"@types/node": "^16.0.0",
153+
"@types/react": "^18.0.25",
154+
"@types/react-dom": "^18.0.9",
157155
"cross-env": "^7.0.3",
158156
"eslint": "^8.21.0",
159157
"eslint-config-react-app": "^7.0.1",

packages/editor/src/app/documentRenderers/notebook/CellListDraggableCell.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Props = {
1212
onAddBefore: () => void;
1313
onAddAfter: () => void;
1414
onRemove: () => void;
15+
children: any;
1516
};
1617

1718
interface DragItem {

packages/editor/src/app/matrix-auth/auth/Registration.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export default class Registration extends React.Component<IProps, IState> {
225225
// do SSO instead. If we've already started the UI Auth process though, we don't
226226
// need to.
227227
if (!this.state.doingUIAuth) {
228-
await this.makeRegisterRequest(null);
228+
await this.makeRegisterRequest(cli, null);
229229
// This should never succeed since we specified no auth object.
230230
console.log("Expecting 401 from register request but got success!");
231231
}
@@ -439,7 +439,7 @@ export default class Registration extends React.Component<IProps, IState> {
439439
});
440440
};
441441

442-
private makeRegisterRequest = (auth: any) => {
442+
private makeRegisterRequest = (matrixClient: MatrixClient, auth: any) => {
443443
// We inhibit login if we're trying to register with an email address: this
444444
// avoids a lot of complex race conditions that can occur if we try to log
445445
// the user in one one or both of the tabs they might end up with after
@@ -461,7 +461,7 @@ export default class Registration extends React.Component<IProps, IState> {
461461
if (auth) registerParams.auth = auth;
462462
if (inhibitLogin !== undefined && inhibitLogin !== null)
463463
registerParams.inhibit_login = inhibitLogin;
464-
return this.state.matrixClient!.registerRequest(registerParams);
464+
return matrixClient.registerRequest(registerParams);
465465
};
466466

467467
private getUIAuthInputs() {
@@ -492,7 +492,9 @@ export default class Registration extends React.Component<IProps, IState> {
492492
return (
493493
<InteractiveAuth
494494
matrixClient={this.state.matrixClient}
495-
makeRequest={this.makeRegisterRequest}
495+
makeRequest={(params) =>
496+
this.makeRegisterRequest(this.state.matrixClient!, params)
497+
}
496498
onAuthFinished={this.onUIAuthFinished}
497499
inputs={this.getUIAuthInputs()}
498500
requestEmailToken={this.requestEmailToken}

packages/editor/src/index.host.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import { Buffer } from "buffer";
77
import * as mobx from "mobx";
88
import * as monaco from "monaco-editor";
99
import * as process from "process";
10-
import React from "react";
11-
import ReactDOM from "react-dom";
10+
import { createRoot } from "react-dom/client";
1211
import App from "./app/App";
1312
import { MATRIX_CONFIG } from "./config/config";
1413
import { validateHostDomain } from "./config/security";
@@ -78,13 +77,15 @@ async function init() {
7877
setupTypecellTypeResolver(monaco);
7978
setupNpmTypeResolver(monaco);
8079

81-
ReactDOM.render(
82-
<React.StrictMode>
83-
<MonacoContext.Provider value={{ monaco }}>
84-
<App config={cachedValidatedConfig} />
85-
</MonacoContext.Provider>
86-
</React.StrictMode>,
87-
document.getElementById("root")
80+
const root = createRoot(document.getElementById("root")!);
81+
82+
root.render(
83+
// TODO: support strictmode
84+
// <React.StrictMode>
85+
<MonacoContext.Provider value={{ monaco }}>
86+
<App config={cachedValidatedConfig} />
87+
</MonacoContext.Provider>
88+
// </React.StrictMode>
8889
);
8990
}
9091

packages/editor/src/index.iframe.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "@atlaskit/css-reset/dist/bundle.css";
22
import React from "react";
3-
import ReactDOM from "react-dom";
43
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4+
import { createRoot } from "react-dom/client";
55
import * as reo from "react-error-overlay";
66
import {
77
getMainDomainFromIframe,
@@ -36,11 +36,11 @@ async function init() {
3636
if (!validateFrameDomain()) {
3737
throw new Error("invalid hostname for frame");
3838
}
39-
ReactDOM.render(
39+
const root = createRoot(document.getElementById("root")!);
40+
root.render(
4041
<React.StrictMode>
4142
<Frame />
42-
</React.StrictMode>,
43-
document.getElementById("root")
43+
</React.StrictMode>
4444
);
4545
}
4646

packages/editor/src/runtime/executor/components/DefaultOutputVisualizer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useEffect, useState } from "react";
2-
import ObjectInspector from "react-inspector";
2+
import { ObjectInspector } from "react-inspector";
33
import { ContainedElement } from "../../../util/ContainedElement";
44
import RetryErrorBoundary from "../../../util/RetryErrorBoundary";
55

packages/editor/src/runtime/executor/components/Output.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ObservableMap, toJS } from "mobx";
22
import { observer } from "mobx-react-lite";
33
import React, { useState } from "react";
4-
import ObjectInspector from "react-inspector";
4+
import { ObjectInspector } from "react-inspector";
55
import { DefaultOutputVisualizer } from "./DefaultOutputVisualizer";
66
import { ModelOutput } from "./ModelOutput";
77

packages/editor/src/runtime/executor/resolver/LocalResolver.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ async function resolveNestedModule(id: string, mode?: string) {
2222
id === "react" &&
2323
(!mode ||
2424
mode === "imports/optimized/react.js" ||
25-
mode === "es2021/react.js")
25+
mode === "es2021/react.js" ||
26+
mode === "es2022/react.js")
2627
) {
2728
return react;
2829
}
2930

30-
if (id === "react" && mode === "imports/unoptimized/jsx-runtime.js") {
31+
if (
32+
(id === "react" && mode === "imports/unoptimized/jsx-runtime.js") ||
33+
id === "react/jsx-runtime"
34+
) {
3135
return jsxruntime;
3236
}
3337

0 commit comments

Comments
 (0)