Skip to content

Commit 9a0f75e

Browse files
committed
fix(vue-query-devtools): guard unmount with mounted flag to prevent SSR crash
1 parent 67b12ae commit 9a0f75e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/vue-query-devtools/src/devtools.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ watchEffect(() => {
3131
devtools.setTheme(props.theme || 'system')
3232
})
3333
34+
let mounted = false
35+
3436
onMounted(() => {
3537
devtools.mount(div.value as HTMLElement)
38+
mounted = true
3639
})
3740
3841
onScopeDispose(() => {
39-
devtools.unmount()
42+
if (mounted) devtools.unmount()
4043
})
4144
</script>
4245

packages/vue-query-devtools/src/devtoolsPanel.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ watchEffect(() => {
3636
devtools.setTheme(props.theme)
3737
})
3838
39+
let mounted = false
40+
3941
onMounted(() => {
4042
devtools.mount(div.value as HTMLElement)
43+
mounted = true
4144
})
4245
4346
onScopeDispose(() => {
44-
devtools.unmount()
47+
if (mounted) devtools.unmount()
4548
})
4649
</script>
4750

0 commit comments

Comments
 (0)