Skip to content

Commit 9aee209

Browse files
committed
fix: resolve TS catch clause type and useVariables race condition
1 parent b4b60d4 commit 9aee209

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ function App() {
481481
)
482482
handleEditorChange(errorVal)
483483
})
484-
} catch (err: Error | unknown) {
484+
} catch (err: unknown) {
485485
const docStr = view.state.doc.toString()
486486
const errorVal = docStr.replace(
487487
'\n\u200B...\u200C\n',

src/hooks/useVariables.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function useVariables() {
77

88
// Sync global variables whenever notes change
99
useEffect(() => {
10+
let abort = false
1011
async function syncVars() {
1112
const globals: Record<string, unknown> = {}
1213
const reVar = /^\/globvar\s+([a-zA-Z0-9_]+)\s*=\s*(.*)$/gm
@@ -27,9 +28,13 @@ export function useVariables() {
2728
}
2829
}
2930
}
31+
if (abort) return
3032
;(window as unknown as { __globalVariables: Record<string, unknown> }).__globalVariables =
3133
globals
3234
}
3335
syncVars()
36+
return () => {
37+
abort = true
38+
}
3439
}, [notes])
3540
}

0 commit comments

Comments
 (0)