Skip to content

Commit

Permalink
fix(reactivity): skip outdated deps
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jan 13, 2024
1 parent c533d3b commit 9d3fe03
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class ReactiveEffect<T = any> {
public get dirty() {
if (this._dirtyLevel === DirtyLevels.MaybeDirty) {
pauseTracking()
for (const dep of this.deps) {
for (let i = 0; i < this._depsLength; i++) {
const dep = this.deps[i]
if (dep.computed) {
triggerComputed(dep.computed)
if (this._dirtyLevel >= DirtyLevels.Dirty) {
Expand Down Expand Up @@ -290,6 +291,10 @@ export function triggerEffects(
) {
pauseScheduling()
for (const effect of dep.keys()) {
if (dep.get(effect) !== effect._trackId) {
// when recurse effect is running, dep map could have outdated items
continue
}
if (effect._dirtyLevel < dirtyLevel) {
const lastDirtyLevel = effect._dirtyLevel
effect._dirtyLevel = dirtyLevel
Expand Down

0 comments on commit 9d3fe03

Please sign in to comment.