Sfoglia il codice sorgente

fix(watch): remove recorded effect on manual stop (#590)

Yang Mingshan 6 anni fa
parent
commit
453e6889da
1 ha cambiato i file con 7 aggiunte e 0 eliminazioni
  1. 7 0
      packages/runtime-core/src/apiWatch.ts

+ 7 - 0
packages/runtime-core/src/apiWatch.ts

@@ -217,6 +217,13 @@ function doWatch(
   recordEffect(runner)
   return () => {
     stop(runner)
+    if (instance) {
+      const effects = instance.effects!
+      const index = effects.indexOf(runner)
+      if (index > -1) {
+        effects.splice(index, 1)
+      }
+    }
   }
 }