Skip to content

Commit 3d82b5a

Browse files
authored
Bump React major version to 19 (#8989)
* Bump react major version to 19 Uh this was painless? I tried to follow https://react.dev/blog/2024/04/25/react-19-upgrade-guide and ran `npx codemod@latest react/19/migration-recipe` and no changes were needed! I want to get access to the new `use` hook. I want to see if it passes tests. * fix: tsc updates
1 parent 7ace97b commit 3d82b5a

18 files changed

+82
-85
lines changed

package-lock.json

Lines changed: 37 additions & 42 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
@@ -61,8 +61,8 @@
6161
"ms": "^2.1.3",
6262
"openid-client": "^5.6.5",
6363
"re-resizable": "^6.11.2",
64-
"react": "^18.3.1",
65-
"react-dom": "^18.2.0",
64+
"react": "19.2.0",
65+
"react-dom": "19.2.0",
6666
"react-hot-toast": "^2.5.2",
6767
"react-hotkeys-hook": "^4.6.1",
6868
"react-modal": "^3.16.3",
@@ -179,8 +179,8 @@
179179
"@types/node": "^22.14.1",
180180
"@types/pixelmatch": "^5.2.6",
181181
"@types/pngjs": "^6.0.4",
182-
"@types/react": "^18.3.4",
183-
"@types/react-dom": "^18.3.1",
182+
"@types/react": "19.2.6",
183+
"@types/react-dom": "19.2.3",
184184
"@types/react-modal": "^3.16.3",
185185
"@types/three": "^0.175.0",
186186
"@types/ua-parser-js": "^0.7.39",

src/components/AvailableVarsHelpers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const AvailableVars = ({
3535

3636
export const addToInputHelper =
3737
(
38-
inputRef: React.RefObject<HTMLInputElement>,
38+
inputRef: React.RefObject<HTMLInputElement | null>,
3939
setValue: (a: string) => void
4040
) =>
4141
(varName: string) => {

src/components/CommandBar/CommandBarTextareaInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function CommandBarTextareaInput({
101101
* Modified from https://www.reddit.com/r/reactjs/comments/twmild/comment/i3jf330/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
102102
* Thank you to @sidkh for the original code
103103
*/
104-
const useTextareaAutoGrow = (ref: RefObject<HTMLTextAreaElement>) => {
104+
const useTextareaAutoGrow = (ref: RefObject<HTMLTextAreaElement | null>) => {
105105
useEffect(() => {
106106
const listener = () => {
107107
if (ref.current === null) return

src/components/CommandBar/CommandBarVector2DInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function CoordinateInput({
2323
value: string
2424
onChange: (value: string) => void
2525
calculation: ReturnType<typeof useCalculateKclExpression>
26-
inputRef: React.RefObject<HTMLInputElement>
26+
inputRef: React.RefObject<HTMLInputElement | null>
2727
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void
2828
testId: string
2929
}) {
@@ -210,7 +210,7 @@ function CommandBarVector2DInput({
210210

211211
function handleKeyDown(
212212
e: React.KeyboardEvent<HTMLInputElement>,
213-
nextInputRef?: React.RefObject<HTMLInputElement>
213+
nextInputRef?: React.RefObject<HTMLInputElement | null>
214214
) {
215215
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
216216
commandBarActor.send({ type: 'Close' })

src/components/CommandBar/CommandBarVector3DInput.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function CoordinateInput({
2323
value: string
2424
onChange: (value: string) => void
2525
calculation: ReturnType<typeof useCalculateKclExpression>
26-
inputRef: React.RefObject<HTMLInputElement>
26+
inputRef: React.RefObject<HTMLInputElement | null>
2727
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void
2828
testId: string
2929
}) {
@@ -232,7 +232,7 @@ function CommandBarVector3DInput({
232232

233233
function handleKeyDown(
234234
e: React.KeyboardEvent<HTMLInputElement>,
235-
nextInputRef?: React.RefObject<HTMLInputElement>
235+
nextInputRef?: React.RefObject<HTMLInputElement | null>
236236
) {
237237
if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
238238
commandBarActor.send({ type: 'Close' })

src/components/ContextMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { hotkeyDisplay } from '@src/lib/hotkeys'
1919
export interface ContextMenuProps
2020
extends Omit<React.HTMLAttributes<HTMLUListElement>, 'children'> {
2121
items?: React.ReactElement[]
22-
menuTargetElement?: RefObject<HTMLElement>
22+
menuTargetElement?: RefObject<HTMLElement | null>
2323
guard?: (e: globalThis.MouseEvent) => boolean
2424
event?: 'contextmenu' | 'mouseup'
2525
callback?: (event: globalThis.MouseEvent) => void

src/components/Explorer/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface FileExplorerRender extends FileExplorerRow {
7171
}
7272

7373
export interface FileExplorerRowContextMenuProps {
74-
itemRef: React.RefObject<HTMLElement>
74+
itemRef: React.RefObject<HTMLElement | null>
7575
onRename: () => void
7676
onDelete: () => void
7777
onOpenInNewWindow: () => void

src/components/MlEphantConversation.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ export const MlEphantConversationInput = (
9595
if (props.disabled) return
9696

9797
const value = refDiv.current?.value
98-
if (!value) return
99-
setHeightConvo(refDiv.current.getBoundingClientRect().height)
98+
const boundingRect = refDiv.current?.getBoundingClientRect()
99+
if (!(value && boundingRect)) return
100+
setHeightConvo(boundingRect.height)
100101

101102
props.onProcess(value)
102103
setLettersForAnimation(

src/components/Settings/KeybindingsSectionsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from '@src/lib/settings/initialKeybindings'
55

66
interface KeybindingSectionsListProps {
7-
scrollRef: React.RefObject<HTMLDivElement>
7+
scrollRef: React.RefObject<HTMLDivElement | null>
88
}
99

1010
export function KeybindingsSectionsList({

0 commit comments

Comments
 (0)