@@ -49,6 +49,7 @@ export enum EffectFlags {
49
49
DIRTY = 1 << 4 ,
50
50
ALLOW_RECURSE = 1 << 5 ,
51
51
PAUSED = 1 << 6 ,
52
+ EVALUATED = 1 << 7 ,
52
53
}
53
54
54
55
/**
@@ -377,22 +378,22 @@ export function refreshComputed(computed: ComputedRefImpl): undefined {
377
378
}
378
379
computed . globalVersion = globalVersion
379
380
380
- const dep = computed . dep
381
- computed . flags |= EffectFlags . RUNNING
382
381
// In SSR there will be no render effect, so the computed has no subscriber
383
382
// and therefore tracks no deps, thus we cannot rely on the dirty check.
384
383
// Instead, computed always re-evaluate and relies on the globalVersion
385
384
// 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.
386
387
if (
387
- dep . version > 0 &&
388
388
! computed . isSSR &&
389
- computed . deps &&
390
- ! isDirty ( computed )
389
+ computed . flags & EffectFlags . EVALUATED &&
390
+ ( ( ! computed . deps && ! ( computed as any ) . _dirty ) || ! isDirty ( computed ) )
391
391
) {
392
- computed . flags &= ~ EffectFlags . RUNNING
393
392
return
394
393
}
394
+ computed . flags |= EffectFlags . RUNNING
395
395
396
+ const dep = computed . dep
396
397
const prevSub = activeSub
397
398
const prevShouldTrack = shouldTrack
398
399
activeSub = computed
@@ -402,6 +403,7 @@ export function refreshComputed(computed: ComputedRefImpl): undefined {
402
403
prepareDeps ( computed )
403
404
const value = computed . fn ( computed . _value )
404
405
if ( dep . version === 0 || hasChanged ( value , computed . _value ) ) {
406
+ computed . flags |= EffectFlags . EVALUATED
405
407
computed . _value = value
406
408
dep . version ++
407
409
}
0 commit comments