Skip to content

Commit

Permalink
refactor: obj[key] have already triggered the getter (#914)
Browse files Browse the repository at this point in the history
Co-authored-by: wavesheep <yanghaibo@youzan.com>
  • Loading branch information
wavesheep and wavesheep committed Mar 29, 2022
1 parent b3296db commit 000ffe4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/reactivity/reactive.ts
Expand Up @@ -208,14 +208,13 @@ export function shallowReactive(obj: any) {

proxy(observed, key, {
get: function getterHandler() {
const value = getter ? getter.call(obj) : val
ob.dep?.depend()
return value
return val
},
set: function setterHandler(newVal: any) {
if (getter && !setter) return
const value = getter ? getter.call(obj) : val
if (!isForceTrigger() && value === newVal) return

if (!isForceTrigger() && val === newVal) return
if (setter) {
setter.call(obj, newVal)
} else {
Expand Down

0 comments on commit 000ffe4

Please sign in to comment.