Просмотр исходного кода

fix(ref): store old value in RefImpl when value changes

daiwei 9 месяцев назад
Родитель
Сommit
51314388e9
1 измененных файлов с 1 добавлено и 0 удалено
  1. 1 0
      packages/reactivity/src/ref.ts

+ 1 - 0
packages/reactivity/src/ref.ts

@@ -168,6 +168,7 @@ class RefImpl<T = any> implements ReactiveNode {
     if (hasChanged(newValue, oldValue)) {
       this.flags |= _ReactiveFlags.Dirty
       this._rawValue = newValue
+      this._oldValue = oldValue
       this._value =
         !useDirectValue && this._wrap ? this._wrap(newValue) : newValue
       const subs = this.subs