Skip to content

Commit 4958c9b

Browse files
committed
Merge branch 'master' into inner-effects
2 parents 171baa2 + 3610e91 commit 4958c9b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export function computed<T>(getter: (previousValue?: T) => T): () => T {
138138
subsTail: undefined,
139139
deps: undefined,
140140
depsTail: undefined,
141-
flags: 17 as ReactiveFlags.Mutable | ReactiveFlags.Dirty,
141+
flags: 0 as ReactiveFlags.None,
142142
getter: getter as (previousValue?: unknown) => unknown,
143143
}) as () => T;
144144
}
@@ -257,6 +257,14 @@ function computedOper<T>(this: Computed<T>): T {
257257
shallowPropagate(subs);
258258
}
259259
}
260+
} else if (!flags) {
261+
this.flags = 1 satisfies ReactiveFlags.Mutable;
262+
const prevSub = setActiveSub(this);
263+
try {
264+
this.value = this.getter();
265+
} finally {
266+
activeSub = prevSub;
267+
}
260268
}
261269
const sub = activeSub;
262270
if (sub !== undefined) {

0 commit comments

Comments
 (0)