You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! Thanks so much for the library, it's been great to use.
We've been trying 4.3.0-alpha.2 to get the react-easy-state fix RisingStack/react-easy-state#184, and ran into a problem using constructors that have been observed -- at least with @babel/plugin-transform-classes. I haven't been able to test without it, but either way the behavior doesn't seem right.
An example might be easiest:
classThing{}constthing=newThing();// => Thing instanceconstobservableThing=observable(thing);// => Proxy wrapping Thing instanceconstConstructor=observableThing.constructor;// => Proxy wrapping Thing()constnewThing=newConstructor();// => Fails with Uncaught TypeError: Cannot call a class as a function
The failure happens because the construct function here is called as
construct(Thing,[],Proxy{Thing()})
When constructing the object, Thing() is called with this set to Proxy { Thing() }.prototype, which is also a Proxy. This means that this instanceof Thing will be false, which seems incorrect.
I think using the raw constructor as newTarget would be the easiest fix, but I don't know whether that's right.
The text was updated successfully, but these errors were encountered:
Hi! Thanks so much for the library, it's been great to use.
We've been trying 4.3.0-alpha.2 to get the react-easy-state fix RisingStack/react-easy-state#184, and ran into a problem using constructors that have been observed -- at least with @babel/plugin-transform-classes. I haven't been able to test without it, but either way the behavior doesn't seem right.
An example might be easiest:
The failure happens because the
construct
function here is called asWhen constructing the object,
Thing()
is called withthis
set toProxy { Thing() }.prototype
, which is also a Proxy. This means thatthis instanceof Thing
will be false, which seems incorrect.I think using the
raw
constructor asnewTarget
would be the easiest fix, but I don't know whether that's right.The text was updated successfully, but these errors were encountered: