@@ -287,6 +287,8 @@ class CustomRefImpl<T> {
287287
288288 public readonly [ ReactiveFlags . IS_REF ] = true
289289
290+ public _value : T = undefined !
291+
290292 constructor ( factory : CustomRefFactory < T > ) {
291293 const dep = ( this . dep = new Dep ( ) )
292294 const { get, set } = factory ( dep . track . bind ( dep ) , dep . trigger . bind ( dep ) )
@@ -295,7 +297,7 @@ class CustomRefImpl<T> {
295297 }
296298
297299 get value ( ) {
298- return this . _get ( )
300+ return ( this . _value = this . _get ( ) )
299301 }
300302
301303 set value ( newVal ) {
@@ -339,6 +341,7 @@ export function toRefs<T extends object>(object: T): ToRefs<T> {
339341
340342class ObjectRefImpl < T extends object , K extends keyof T > {
341343 public readonly [ ReactiveFlags . IS_REF ] = true
344+ public _value : T [ K ] = undefined !
342345
343346 constructor (
344347 private readonly _object : T ,
@@ -348,7 +351,7 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
348351
349352 get value ( ) {
350353 const val = this . _object [ this . _key ]
351- return val === undefined ? this . _defaultValue ! : val
354+ return ( this . _value = val === undefined ? this . _defaultValue ! : val )
352355 }
353356
354357 set value ( newVal ) {
@@ -363,9 +366,11 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
363366class GetterRefImpl < T > {
364367 public readonly [ ReactiveFlags . IS_REF ] = true
365368 public readonly [ ReactiveFlags . IS_READONLY ] = true
369+ public _value : T = undefined !
370+
366371 constructor ( private readonly _getter : ( ) => T ) { }
367372 get value ( ) {
368- return this . _getter ( )
373+ return ( this . _value = this . _getter ( ) )
369374 }
370375}
371376
0 commit comments