Skip to content

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

Closed
@jdittrich

Description

@jdittrich

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions