Skip to content

Commit 4bbc7a7

Browse files
authored
playground: adjust react compiler to fail build on error (#735)
1 parent 13647c2 commit 4bbc7a7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

playground/src/App.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,22 @@ function initialMode(): Mode | null {
8080
return "Lint"
8181
}
8282

83+
// pulling this into its own function due to gap in react compiler
84+
// https://github.com/facebook/react/issues/34761
85+
// this avoid a de-opt
86+
function saveMode(mode: Mode | null) {
87+
try {
88+
localStorage.setItem("play-mode-v1", mode ?? "none")
89+
} catch {
90+
// pass
91+
}
92+
}
93+
8394
function useMode() {
8495
const [mode, setActiveMode] = useState<Mode | null>(() => initialMode())
8596

8697
useEffect(() => {
87-
try {
88-
localStorage.setItem("play-mode-v1", mode ?? "none")
89-
} catch {
90-
// pass
91-
}
98+
saveMode(mode)
9299
}, [mode])
93100

94101
return [mode, setActiveMode] as const

playground/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { sentryVitePlugin } from "@sentry/vite-plugin"
33
import react from "@vitejs/plugin-react"
44
import tailwindcss from "@tailwindcss/vite"
55

6-
const ReactCompilerConfig = {}
6+
const ReactCompilerConfig = { panicThreshold: "all_errors" }
77

88
// https://vite.dev/config/
99
export default defineConfig({

0 commit comments

Comments
 (0)