Skip to content

Commit 0ba9457

Browse files
authored
React18 (#2504)
* Upgrade React and corresponding types to latest version * Deprecate usage of React.SFC * Fix miscellaneous type errors * Upgrade react-konva to fix type errors with react18 * Fix typings for react-sortable-hoc * Shift root render to new API * Fix @types/react versioning * Fix navigation bar typing * Fix useEffect return type * Upgrade @testing-library/react and react-test-renderer to match react v18 and fix tests * Workaround deprecated ReactDOM.render used by Blueprintjs v4 * Update notification import lines
1 parent 56867f9 commit 0ba9457

File tree

61 files changed

+257
-176
lines changed

Some content is hidden

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

61 files changed

+257
-176
lines changed

package.json

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@
4848
"flexboxgrid": "^6.3.1",
4949
"flexboxgrid-helpers": "^1.1.3",
5050
"js-slang": "^1.0.23",
51-
"konva": "^8.3.14",
51+
"konva": "^9.2.0",
5252
"lodash": "^4.17.21",
5353
"lz-string": "^1.4.4",
5454
"moment": "^2.29.4",
5555
"normalize.css": "^8.0.1",
5656
"phaser": "^3.55.2",
5757
"query-string": "^7.1.1",
5858
"re-resizable": "^6.9.9",
59-
"react": "^17.0.2",
59+
"react": "^18.2.0",
6060
"react-ace": "^10.1.0",
6161
"react-copy-to-clipboard": "^5.1.0",
62-
"react-dom": "^17.0.2",
62+
"react-dom": "^18.2.0",
6363
"react-draggable": "^4.4.5",
6464
"react-dropzone": "^14.2.3",
6565
"react-hotkeys": "^2.0.0",
66-
"react-konva": "^17.0.2-5",
66+
"react-konva": "^18.2.10",
6767
"react-latex-next": "^2.1.0",
6868
"react-mde": "^11.5.0",
6969
"react-papaparse": "^4.0.2",
@@ -89,8 +89,8 @@
8989
"@craco/craco": "^7.1.0",
9090
"@svgr/webpack": "^6.3.1",
9191
"@testing-library/jest-dom": "^5.16.5",
92-
"@testing-library/react": "12.1.2",
93-
"@testing-library/user-event": "^14.3.0",
92+
"@testing-library/react": "^14.0.0",
93+
"@testing-library/user-event": "^14.4.3",
9494
"@types/acorn": "^6.0.0",
9595
"@types/gapi": "^0.0.44",
9696
"@types/gapi.auth2": "^0.0.57",
@@ -100,15 +100,15 @@
100100
"@types/jest": "^28.1.6",
101101
"@types/lodash": "^4.14.195",
102102
"@types/lz-string": "^1.3.34",
103-
"@types/react": "^17.0.38",
103+
"@types/react": "^18.2.13",
104104
"@types/react-copy-to-clipboard": "^5.0.4",
105-
"@types/react-dom": "^17.0.20",
105+
"@types/react-dom": "^18.2.6",
106106
"@types/react-redux": "^7.1.24",
107107
"@types/react-responsive": "^8.0.5",
108108
"@types/react-router": "^5.1.20",
109109
"@types/react-router-dom": "^5.3.3",
110110
"@types/react-syntax-highlighter": "^15.5.7",
111-
"@types/react-test-renderer": "^17.0.2",
111+
"@types/react-test-renderer": "^18.0.0",
112112
"@types/react-textarea-autosize": "^8.0.0",
113113
"@types/redux-mock-store": "^1.0.3",
114114
"@types/showdown": "^2.0.1",
@@ -130,7 +130,7 @@
130130
"process": "^0.11.10",
131131
"react-error-overlay": "^6.0.11",
132132
"react-scripts": "^5.0.1",
133-
"react-test-renderer": "^17.0.2",
133+
"react-test-renderer": "^18.2.0",
134134
"redux-saga-test-plan": "^4.0.6",
135135
"resize-observer-polyfill": "^1.5.1",
136136
"sass": "^1.62.1",
@@ -141,10 +141,6 @@
141141
"url": "^0.11.0",
142142
"webpack-bundle-analyzer": "^4.9.0"
143143
},
144-
"resolutions": {
145-
"//": "React 18's types are much stricter and upgrading to it (even if indirectly via a dependency) results in many type errors. FIXME: Remove this after upgrading fully to React 18 and fixing all of the type errors.",
146-
"@types/react": "^17.0.38"
147-
},
148144
"browserslist": {
149145
"production": [
150146
"Firefox ESR",

src/commons/ContentDisplay.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ export type ContentDisplayProps = {
88
};
99

1010
const ContentDisplay: React.FC<ContentDisplayProps> = props => {
11-
// eslint-disable-next-line react-hooks/exhaustive-deps
12-
useEffect(() => props.loadContentDispatch?.(), []);
11+
useEffect(() => {
12+
props.loadContentDispatch?.();
13+
// eslint-disable-next-line react-hooks/exhaustive-deps
14+
}, []);
1315

1416
return (
1517
<div className="ContentDisplay row center-xs">

src/commons/achievement/AchievementCommentCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router';
33

44
import { Assessment } from '../assessment/AssessmentTypes';
55
import { useTypedSelector } from '../utils/Hooks';
6-
import { showWarningMessage } from '../utils/NotificationsHelper';
6+
import { showWarningMessage } from '../utils/notifications/NotificationsHelper';
77
import { assessmentTypeLink } from '../utils/ParamParseHelper';
88

99
const AchievementCommentCard = ({

src/commons/achievement/AchievementManualEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
GoalProgress
99
} from 'src/features/achievement/AchievementTypes';
1010

11-
import { showSuccessMessage, showWarningMessage } from '../utils/NotificationsHelper';
11+
import { showSuccessMessage, showWarningMessage } from '../utils/notifications/NotificationsHelper';
1212

1313
type AchievementManualEditorProps = {
1414
hiddenState: [boolean, any];

src/commons/achievement/control/achievementEditor/AchievementUuidCopier.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
33
import { Tooltip2 } from '@blueprintjs/popover2';
4-
import { showSuccessMessage } from 'src/commons/utils/NotificationsHelper';
4+
import { showSuccessMessage } from 'src/commons/utils/notifications/NotificationsHelper';
55

66
type AchievementUuidCopierProps = {
77
uuid: string;

src/commons/achievement/control/common/ItemSaver.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Button } from '@blueprintjs/core';
22
import { IconNames } from '@blueprintjs/icons';
33
import { Tooltip2 } from '@blueprintjs/popover2';
4-
import { showSuccessMessage, showWarningMessage } from 'src/commons/utils/NotificationsHelper';
4+
import {
5+
showSuccessMessage,
6+
showWarningMessage
7+
} from 'src/commons/utils/notifications/NotificationsHelper';
58

69
type ItemSaverProps = {
710
discardChanges: () => void;

src/commons/achievement/utils/AchievementInferencer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
GoalProgress,
1111
GoalType
1212
} from '../../../features/achievement/AchievementTypes';
13-
import { showDangerMessage } from '../../utils/NotificationsHelper';
13+
import { showDangerMessage } from '../../utils/notifications/NotificationsHelper';
1414
import { isExpired, isReleased } from './DateHelper';
1515

1616
/**

src/commons/achievement/utils/EventHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
GoalProgress,
77
GoalType
88
} from '../../../features/achievement/AchievementTypes';
9-
import { showSuccessMessage } from '../../utils/NotificationsHelper';
9+
import { showSuccessMessage } from '../../utils/notifications/NotificationsHelper';
1010
import AchievementInferencer from './AchievementInferencer';
1111
import { isExpired, isReleased, isWithinTimeRange } from './DateHelper';
1212

src/commons/assessment/__tests__/__snapshots__/Assessment.tsx.snap

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,7 @@ exports[`Assessment page with multiple loaded missions renders correctly 1`] = `
10911091
</span>
10921092
<span
10931093
className="custom-hidden-xxs"
1094-
>
1095-
1096-
</span>
1094+
/>
10971095
</span>
10981096
</button>
10991097
</a>

src/commons/controlBar/ControlBarSessionButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as CopyToClipboard from 'react-copy-to-clipboard';
66

77
import { checkSessionIdExists, createNewSession } from '../collabEditing/CollabEditingHelper';
88
import ControlButton from '../ControlButton';
9-
import { showWarningMessage } from '../utils/NotificationsHelper';
9+
import { showWarningMessage } from '../utils/notifications/NotificationsHelper';
1010

1111
type ControlBarSessionButtonsProps = DispatchProps & StateProps;
1212

0 commit comments

Comments
 (0)