@@ -49,6 +49,7 @@ export enum EffectFlags {
4949 DIRTY = 1 << 4 ,
5050 ALLOW_RECURSE = 1 << 5 ,
5151 PAUSED = 1 << 6 ,
52+ EVALUATED = 1 << 7 ,
5253}
5354
5455/**
@@ -377,22 +378,22 @@ export function refreshComputed(computed: ComputedRefImpl): undefined {
377378 }
378379 computed . globalVersion = globalVersion
379380
380- const dep = computed . dep
381- computed . flags |= EffectFlags . RUNNING
382381 // In SSR there will be no render effect, so the computed has no subscriber
383382 // and therefore tracks no deps, thus we cannot rely on the dirty check.
384383 // Instead, computed always re-evaluate and relies on the globalVersion
385384 // fast path above for caching.
385+ // #12337 if computed has no deps (does not rely on any reactive data) and evaluated,
386+ // there is no need to re-evaluate.
386387 if (
387- dep . version > 0 &&
388388 ! computed . isSSR &&
389- computed . deps &&
390- ! isDirty ( computed )
389+ computed . flags & EffectFlags . EVALUATED &&
390+ ( ( ! computed . deps && ! ( computed as any ) . _dirty ) || ! isDirty ( computed ) )
391391 ) {
392- computed . flags &= ~ EffectFlags . RUNNING
393392 return
394393 }
394+ computed . flags |= EffectFlags . RUNNING
395395
396+ const dep = computed . dep
396397 const prevSub = activeSub
397398 const prevShouldTrack = shouldTrack
398399 activeSub = computed
@@ -402,6 +403,7 @@ export function refreshComputed(computed: ComputedRefImpl): undefined {
402403 prepareDeps ( computed )
403404 const value = computed . fn ( computed . _value )
404405 if ( dep . version === 0 || hasChanged ( value , computed . _value ) ) {
406+ computed . flags |= EffectFlags . EVALUATED
405407 computed . _value = value
406408 dep . version ++
407409 }
0 commit comments