Skip to content

Commit 284e57c

Browse files
Update react monorepo to v19 (major) (#503)
* Update react monorepo to v19 * Reformat and remove `JSX` namespace usage * Update docs and peer dependencies range * Fix ref type breaking changes * Drop React 18 from peer deps * Fix devserver compile error --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Richard Dominick <34370238+RichDom2185@users.noreply.github.com>
1 parent e894065 commit 284e57c

42 files changed

Lines changed: 237 additions & 251 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

devserver/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
"commander": "^14.0.0",
2020
"js-slang": "^1.0.85",
2121
"re-resizable": "^6.9.11",
22-
"react": "^18.3.1",
22+
"react": "^19.0.0",
2323
"react-ace": "^14.0.0",
24-
"react-dom": "^18.3.1",
24+
"react-dom": "^19.0.0",
2525
"vite": "^8.0.5",
2626
"vite-plugin-node-polyfills": "^0.26.0"
2727
},
2828
"devDependencies": {
2929
"@sourceacademy/modules-buildtools": "workspace:^",
30-
"@types/react": "^18.3.1",
31-
"@types/react-dom": "^18.3.1",
30+
"@types/react": "^19.0.0",
31+
"@types/react-dom": "^19.0.0",
3232
"@vitest/browser-playwright": "4.1.0",
3333
"eslint": "^9.35.0",
3434
"playwright": "^1.55.1",

devserver/src/components/controlBar/ControlBar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Classes } from '@blueprintjs/core';
22
import classNames from 'classnames';
3-
import React, { type JSX } from 'react';
3+
import React from 'react';
44

55
export type ControlBarProps = {
6-
editorButtons: Array<JSX.Element | null>;
7-
flowButtons?: Array<JSX.Element | null>;
8-
editingWorkspaceButtons?: Array<JSX.Element | null>;
6+
editorButtons: Array<React.ReactElement | null>;
7+
flowButtons?: Array<React.ReactElement | null>;
8+
editingWorkspaceButtons?: Array<React.ReactElement | null>;
99
};
1010

1111
const ControlBar: React.FC<ControlBarProps> = (props) => {

devserver/src/components/repl/Repl.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ const Output: React.FC<OutputProps> = (props: OutputProps) => {
6868
};
6969

7070
export type ReplProps = {
71-
// replButtons: Array<JSX.Element | null>;
7271
output: InterpreterOutput | null;
7372
hidden?: boolean;
7473
inputHidden?: boolean;
@@ -80,7 +79,7 @@ const Repl: React.FC<ReplProps> = (props: ReplProps) => (
8079
<div className="repl-output-parent">
8180
{props.output === null
8281
? <Card />
83-
: <Output output={props.output}/>}
82+
: <Output output={props.output} />}
8483
{/* {cards.length > 0 ? cards : (<Card />)} */}
8584
</div>
8685
</div>

devserver/src/components/sideContent/SideContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const renderTab = (
5959
return <Tab key={tab.id} {...tabProps} />;
6060
}
6161

62-
const tabPanel: React.JSX.Element = <div className="side-content-text">{tab.body}</div>;
62+
const tabPanel: React.ReactElement = <div className="side-content-text">{tab.body}</div>;
6363

6464
return <Tab key={tab.id} {...tabProps} panel={tabPanel} />;
6565
};

devserver/src/components/sideContent/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export type SideContentTab = {
1111
id: string;
1212
label: string;
1313
iconName: IconName;
14-
body: React.JSX.Element;
14+
body: React.ReactElement;
1515
};
1616

1717
export type ModuleSideContent = {
1818
label: string;
1919
iconName: IconName;
2020
toSpawn?: (context: DebuggerContext) => boolean;
21-
body: (context: DebuggerContext) => React.JSX.Element;
21+
body: (context: DebuggerContext) => React.ReactElement;
2222
};
2323

2424
export type RawTab = (provider: ReturnType<typeof requireProvider>, react: typeof React) => Promise<{ default: ModuleSideContent }>;

devserver/src/components/utils/Hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React, { type RefObject } from 'react';
99

10-
export const useDimensions = (ref: RefObject<HTMLElement>): [width: number, height: number] => {
10+
export const useDimensions = (ref: RefObject<HTMLElement | null>): [width: number, height: number] => {
1111
const [width, setWidth] = React.useState<number>(0);
1212
const [height, setHeight] = React.useState<number>(0);
1313

docs/src/modules/2-bundle/3-editing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This adds the dependency to `devDependencies` instead.
4343
> specified in the root repository `package.json`:
4444
>
4545
> ```sh
46-
> yarn add react@^18.3.1
46+
> yarn add react@^19.0.0
4747
> ```
4848
>
4949
> You can also use the command `yarn constraints` to check if you have incorrectly specified the version of a dependency. You can view all

docs/src/modules/3-tabs/1-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The Frontend expects each tab's entry point to provide a default export of an ob
6767
```ts
6868
interface ModuleSideContent {
6969
toSpawn: ((context: DebuggerContext) => boolean) | undefined;
70-
body: (context: DebuggerContext) => JSX.Element;
70+
body: (context: DebuggerContext) => React.ReactElement;
7171
label: string;
7272
iconName: string;
7373
}

docs/src/modules/3-tabs/3-editing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This adds the dependency to `devDependencies` instead.
4343
> specified in the root repository `package.json`:
4444
>
4545
> ```sh
46-
> yarn add react@^18.3.1
46+
> yarn add react@^19.0.0
4747
> ```
4848
>
4949
> You can also use the command `yarn constraints` to check if you have incorrectly specified the version of a dependency. You can view all

docs/src/repotools/5-yarn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ As part of ensuring consistency, everything in this repository has been designed
2828
Tabs, for example, should all be using the same versions of `react` and `react-dom`: the one in use by the frontend. If a dependency is specified in the root `package.json`, then the constraints file
2929
requires that all child workspaces use the version of that dependency.
3030

31-
For example, the root package specifies `react@^18.3.1` as a dependency, so all workspaces that require React must also use that version spec.
31+
For example, the root package specifies `react@^19.0.0` as a dependency, so all workspaces that require React must also use that version spec.
3232

3333
This validation is not carried out across child workspaces, however. Two different bundles could use two different versions of the same package. This should not cause an issue **unless** the bundles are somehow dependent on each other.
3434

0 commit comments

Comments
 (0)