Skip to content

Commit 5164e99

Browse files
committed
improve code
improve code improve code
1 parent 3a89cf7 commit 5164e99

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/reactivity/src/effectScope.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ export class EffectScope {
7676

7777
stop(fromParent?: boolean) {
7878
if (this.active) {
79-
this.effects.forEach(e => e.stop())
8079
let i, l
80+
// #5783
81+
// effects maybe changed when an effect stoped.
82+
// so we need to copy it for iteration.
83+
const effectsToStop = this.effects.slice()
84+
for (i = 0, l = effectsToStop.length; i < l; i++) {
85+
effectsToStop[i].stop()
86+
}
8187
for (i = 0, l = this.cleanups.length; i < l; i++) {
8288
this.cleanups[i]()
8389
}

0 commit comments

Comments
 (0)