Two problems of Proxy
Version
3.0.0-rc.10
Reproduction link
https://codepen.io/wgjas2/pen/VwaxpNX
Steps to reproduce
Problem 1:
When some library use WeakMap in class like:
- outer class:
const privates = new WeakMap()
- class constructor:
privates.set(this, ...)
- class method:
const weakobj = privates.get(this)
now
weakobj
is valueundefined
, because thatthis
in method is Proxy(this) ...... then Proxy(this) !== this,so WeakMap not working.
Problem 2:
When use some library (like Cesium&EarthSDK、Three.js) can create huge data in object, Proxy(obj) cause 2x~4x memory use
What is expected?
have a solution to make object not to Proxy
What is actually happening?
- Proxy not compatible WeakMap
- Huge memory use
Proxies will always have different identity from its target. The best practice is to never keep a reference of the raw object and only work with the reactive version of it.