Skip to content

Proxy vs. original identity – add/explain behavior in ref and reactive and of pass-by(copy/value) values #787

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

Closed
jdittrich opened this issue Jan 7, 2021 · 1 comment · Fixed by #934
Assignees
Labels
enhancement New feature or request

Comments

@jdittrich
Copy link

the section proxy vs. original identity states that a proxy is not identical to the original object it wraps.

I assume proxy means the use of reactive(myObject) or ref(myValue).

Indeed,

let data = {myObject:{myNumber:3}}
let reactiveData = reactive(newData);
data === reactiveData; // → false

And it also applies to nested objects

data.myObject === reactiveData.myObject // → false

However, what the guide does not mention is that this does not apply to the properties as long as they are not objects themselves

data.myObject.myNumber === reactiveData.myObject.myNumber // → true

This also applies to the example which gives the caveat for the strong-comparison array methods like .find

let myArray = [1,2,3,4]
let myReactiveArray = reactive(myArray);
 myReactiveArray.find(number => number === 2) === myArray[1] //→ true

My suggestions would be:

  • Illustrate that proxy in vue can mean using the implicitly proxied values in the method’s API or ref/reactive in the composition API.
  • Tell, that while proxied objects are not equal their original, pass-by-value types (number,string) are.
@skirtles-code skirtles-code added the enhancement New feature or request label Feb 1, 2021
@skirtles-code skirtles-code self-assigned this Feb 1, 2021
@skirtles-code
Copy link
Contributor

I'm currently working on some other changes to this page, including #524, so I'll try to address some of these points as part of that.

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

Successfully merging a pull request may close this issue.

2 participants