Skip to content

Commit ee31244

Browse files
authored
playground: bump react to 19 (#671)
1 parent 2660418 commit ee31244

File tree

3 files changed

+68
-65
lines changed

3 files changed

+68
-65
lines changed

playground/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
"lz-string": "^1.5.0",
1818
"monaco-editor": "^0.52.2",
1919
"prettier": "^3.6.2",
20-
"react": "^19.1.1",
21-
"react-dom": "^19.1.1",
20+
"react": "^19.2.0",
21+
"react-dom": "^19.2.0",
2222
"tailwindcss": "^4.1.12"
2323
},
2424
"devDependencies": {
2525
"@eslint/js": "^9.34.0",
26-
"@types/react": "^19.1.12",
27-
"@types/react-dom": "^19.1.9",
26+
"@types/react": "^19.2.0",
27+
"@types/react-dom": "^19.2.0",
2828
"@vitejs/plugin-react": "^4.7.0",
29-
"babel-plugin-react-compiler": "19.1.0-rc.1",
29+
"babel-plugin-react-compiler": "19.1.0-rc.3",
3030
"eslint": "^9.34.0",
31-
"eslint-plugin-react-hooks": "6.0.0-rc1",
31+
"eslint-plugin-react-hooks": "6.1.0",
3232
"eslint-plugin-react-refresh": "^0.4.20",
3333
"globals": "^15.15.0",
3434
"typescript": "~5.7.3",

playground/pnpm-lock.yaml

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

playground/src/App.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { useState, useEffect, useLayoutEffect, useRef } from "react"
1+
import {
2+
useState,
3+
useEffect,
4+
useLayoutEffect,
5+
useRef,
6+
useEffectEvent,
7+
} from "react"
28
import * as monaco from "monaco-editor"
39
import { LintError, Fix, useDumpCst, useDumpTokens, useErrors } from "./squawk"
410
import {
@@ -233,22 +239,18 @@ function Editor({
233239
settings: monaco.editor.IStandaloneEditorConstructionOptions
234240
markers?: Marker[]
235241
}) {
236-
const onChangeRef = useRef<((_: string) => void) | undefined>(null)
237-
const onSaveRef = useRef<((_: string) => void) | undefined>(null)
242+
const onChangeText = useEffectEvent((text: string) => {
243+
onChange?.(text)
244+
})
245+
const onSaveText = useEffectEvent((text: string) => {
246+
onSave?.(text)
247+
})
238248
const divRef = useRef<HTMLDivElement>(null)
239249
const autoFocusRef = useRef(autoFocus)
240250
const settingsInitial = useRef(settings)
241251
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>(null)
242252
const fixesRef = useRef<Map<string, Fix>>(new Map())
243253

244-
// TODO: replace with useEventEffect
245-
useEffect(() => {
246-
onChangeRef.current = onChange
247-
}, [onChange])
248-
useEffect(() => {
249-
onSaveRef.current = onSave
250-
}, [onSave])
251-
252254
useEffect(() => {
253255
if (markers == null) {
254256
return
@@ -275,10 +277,10 @@ function Editor({
275277
settingsInitial.current,
276278
)
277279
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () =>
278-
onSaveRef.current?.(editor.getValue()),
280+
onSaveText(editor.getValue()),
279281
)
280282
editor.onDidBlurEditorText(() => {
281-
onSaveRef.current?.(editor.getValue())
283+
onSaveText(editor.getValue())
282284
})
283285
monaco.languages.register({ id: "rast" })
284286
const tokenProvider = monaco.languages.setMonarchTokensProvider("rast", {
@@ -346,7 +348,7 @@ function Editor({
346348
)
347349

348350
editor.onDidChangeModelContent(() => {
349-
onChangeRef.current?.(editor.getValue())
351+
onChangeText(editor.getValue())
350352
})
351353
if (autoFocusRef.current) {
352354
editor.focus()

0 commit comments

Comments
 (0)