From e5b9f643e198fab09de8e6dd6d0c26406b45631d Mon Sep 17 00:00:00 2001 From: chris Date: Sun, 24 May 2026 21:52:39 -0400 Subject: [PATCH] Fix TDZ crash: move useEffect hooks to after runLint declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit useEffect(() => {...}, [runLint]) evaluated [runLint] immediately, but runLint was declared with const on the next line — temporal dead zone. Moved both effects to after the useCallback closes. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/components/Editor.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Editor.jsx b/frontend/src/components/Editor.jsx index 97e1cfb..82fee85 100644 --- a/frontend/src/components/Editor.jsx +++ b/frontend/src/components/Editor.jsx @@ -153,11 +153,6 @@ const Editor = forwardRef(function Editor( }, [editor, content]) // ── Lint check ─────────────────────────────────────────────────────────── - // Keep ref in sync so the onUpdate closure (which never re-captures) always - // calls the latest version of runLint. - useEffect(() => { runLintRef.current = runLint }, [runLint]) - useEffect(() => () => clearTimeout(lintDebounce.current), []) - const runLint = useCallback(async () => { if (!editor || lintStatusRef.current === 'checking') return lintStatusRef.current = 'checking' @@ -208,6 +203,11 @@ const Editor = forwardRef(function Editor( } }, [editor]) + // Keep ref in sync so the stale onUpdate closure always calls the latest runLint + useEffect(() => { runLintRef.current = runLint }, [runLint]) + // Clean up the debounce timer on unmount + useEffect(() => () => clearTimeout(lintDebounce.current), []) + // ── Popover on clicking a lint mark ────────────────────────────────────── function handleEditorClick(e) { if (!editor) return