Fix TDZ crash: move useEffect hooks to after runLint declaration
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 <noreply@anthropic.com>
This commit is contained in:
parent
91071270a4
commit
e5b9f643e1
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user