diff --git a/playground/src/App.tsx b/playground/src/App.tsx index dece20cd..a53752f8 100644 --- a/playground/src/App.tsx +++ b/playground/src/App.tsx @@ -80,15 +80,22 @@ function initialMode(): Mode | null { return "Lint" } +// pulling this into its own function due to gap in react compiler +// https://github.com/facebook/react/issues/34761 +// this avoid a de-opt +function saveMode(mode: Mode | null) { + try { + localStorage.setItem("play-mode-v1", mode ?? "none") + } catch { + // pass + } +} + function useMode() { const [mode, setActiveMode] = useState(() => initialMode()) useEffect(() => { - try { - localStorage.setItem("play-mode-v1", mode ?? "none") - } catch { - // pass - } + saveMode(mode) }, [mode]) return [mode, setActiveMode] as const diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 32c28081..7a13cdcc 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -3,7 +3,7 @@ import { sentryVitePlugin } from "@sentry/vite-plugin" import react from "@vitejs/plugin-react" import tailwindcss from "@tailwindcss/vite" -const ReactCompilerConfig = {} +const ReactCompilerConfig = { panicThreshold: "all_errors" } // https://vite.dev/config/ export default defineConfig({