Skip to content

Commit 7bc5fd9

Browse files
committed
chore(sfc-playground): teardown preview update watcher
1 parent ebf3962 commit 7bc5fd9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/sfc-playground/src/output/Preview.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<script setup lang="ts">
1313
import Message from '../Message.vue'
1414
import { ref, onMounted, onUnmounted, watchEffect } from 'vue'
15+
import type { WatchStopHandle } from 'vue'
1516
import srcdoc from './srcdoc.html?raw'
1617
import { PreviewProxy } from './PreviewProxy'
1718
import { MAIN_FILE, SANDBOX_VUE_URL } from '../sfcCompiler'
@@ -22,6 +23,7 @@ const runtimeError = ref()
2223
const runtimeWarning = ref()
2324
2425
let proxy: PreviewProxy
26+
let updateHandle: WatchStopHandle
2527
2628
async function updatePreview() {
2729
runtimeError.value = null
@@ -93,12 +95,13 @@ onMounted(() => {
9395
9496
iframe.value.addEventListener('load', () => {
9597
proxy.handle_links()
96-
watchEffect(updatePreview)
98+
updateHandle = watchEffect(updatePreview)
9799
})
98100
})
99101
100102
onUnmounted(() => {
101103
proxy.destroy()
104+
updateHandle && updateHandle()
102105
})
103106
</script>
104107

0 commit comments

Comments
 (0)