Skip to content

Commit

Permalink
fix activeEffect equal null
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixiaorui committed Aug 21, 2021
1 parent 4cacb1c commit df7ecf4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/reactivity/src/effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ export function track(target, type, key) {

export function trackEffects(dep) {
// 用 dep 来存放所有的 effect
let shouldTrack = false;

// TODO
// 这里是一个优化点
// 先看看这个依赖是不是已经收集了,
// 已经收集的话,那么就不需要在收集一次了
// 可能会影响 code path change 的情况
// 需要每次都 cleanupEffect
// shouldTrack = !dep.has(activeEffect!);

// if (!shouldTrack) return;
if (!activeEffect) return;

dep.add(activeEffect);
(activeEffect as any).deps.push(dep);
}
Expand Down

0 comments on commit df7ecf4

Please sign in to comment.