-
Notifications
You must be signed in to change notification settings - Fork 129
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
this
inside arrow function is incorrect after Solid transform
#292
Comments
Yeah seems like edit: dom-expressions/packages/babel-plugin-jsx-dom-expressions/src/shared/transform.js Line 50 in 82c377d
This is the culprit. The workaround could be to find the nearest function or block parent, and then move the declaration there. |
Why do we need a declaration? Why not leave |
@trusktr It's to protect reactive properties from accessing the props object. For example: <Div title={this.title} />
// if preserved
createComponent(Div, {
get title() {
return this.title; // recursive
},
}); Origin: ryansolid/mobx-jsx#44 |
Reproduction:
https://playground.solidjs.com/anonymous/ab9e79a2-8bb0-4e1d-96cd-f55b12d0242e
A workaround is to avoid arrow functions, here with a regular method:
https://playground.solidjs.com/anonymous/e80be486-0bc4-4512-b4d0-c1dad21ee863
The transform is replacing
this
with a variable that grabsthis
from somewhere unrelated to the code, f.e. like so:At the top level of a module,
this
isundefined
.The text was updated successfully, but these errors were encountered: