Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: 访问 reactive 里面 ref 类型的值 #115

Open
Jayden12138 opened this issue Mar 21, 2024 · 3 comments · May be fixed by #116
Open

TODO: 访问 reactive 里面 ref 类型的值 #115

Jayden12138 opened this issue Mar 21, 2024 · 3 comments · May be fixed by #116

Comments

@Jayden12138
Copy link

TODO reactive 里面如果有 ref 类型的 key 的话, 那么也是不需要调用 ref.value 的

在阅读源码时发现了一个TODO,想解决下

@Jayden12138
Copy link
Author

单测如下:

  it('should automatically dereference reactive properties with proxyRefs', () => {
    const user = {
      age: ref(10),
      name: 'xiaohong'
    }
    const original = reactive(user)
    const proxyUser = proxyRefs(original)
  
    expect(proxyUser).toBe(original)
    expect(proxyUser.age).toBe(10)
  })

@Jayden12138 Jayden12138 linked a pull request Mar 21, 2024 that will close this issue
@Grothendieck42
Copy link

export function isRef(value) {
  return !!(value && value.__v_isRef === true)
}

isRef也需要改动

@Jayden12138
Copy link
Author

export function isRef(value) {
  return !!(value && value.__v_isRef === true)
}

isRef也需要改动

已更正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants