Customize scope for arrow functions #679
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #391 and (already closed) #242
@neoziro, this is the same idea, that I mentioned in your PR.
Problem – react-proxy instances
ES5 classes
with correctthis
, but cannot repeat the trick with ES6 classes, as result new Components will be created with their own contexts.In other word -
this
in arrow function will target thereal
component, but one can use only the proxied one.Solution - store pointer to the proxy context inside instance, and use it.
This PR does include just a change of babel plugin, to work normally it requires changes in react-proxy, but version 3, used by RHL is not public :(
The one, who wants repeat the trick - just copy-paste code to the createProxyClass.js
Tested both in es5 and es6 environments – all green.