-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Separate React Composite and Class #2445
Conversation
fa628aa
to
48b978a
Compare
@sebmarkbage I don't really feel all that familiar with these specifics so it's a bit beyond me, but I think everything you said makes sense. You've probably talked this through in a meeting, but could it make more sense to expose it as EDIT: PS. What happens to auto-binding? ES6 classes don't come with that by default AFAIK. |
The idea is to expose whatever is on ReactClassMixin as a base class. Such as Yea, auto-binding wouldn't work. You have to explicitly bind, or use ES.next property initializers to do the auto-binding: |
That sounds like a bad idea, your work on moving away from all magic stuff is great. I could see a benefit in exposing an auto-bind enhanced base class (preferably as addon) for those who are still OK with it until ES7+ provides a proper solution. Especially as it is preferable performance-wise to use auto-binding over manually binding (but perhaps the actual benefit is minimal?). |
The actual benefit is minimal. It helps with referential equality checks though. You can have a |
@sebmarkbage The equality check is already somewhat compromised for those of us not religiously componentizing and sometimes bind index/id to callbacks. Perhaps one might even shed some composite component house keeping overhead (at creation) from dropping the auto-binding? That would be a win, but I imagine it would be "minimal" as well... anyway, I'm personally all for as little magic as possible "by default/in core". |
+1 for less magic. Using ES7 property initializers with arrow functions is very appealing to me, though I understand the reluctance to introduce more syntax or a dependence on unstandardized features. Haven't had a chance to read through the diff yet. |
@@ -126,6 +128,27 @@ function getNode(id) { | |||
} | |||
|
|||
/** | |||
* Finds the node with the supplied React-generated DOM ID. | |||
* | |||
* @param {string} id A React-generated DOM ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
come on
I addressed the comments so... stamp? |
I apparently add labels from mobile so 👍 |
ReactClass is now composed by ReactCompositeComponent rather than inherit from it. The state transition functions currently use ReactInstanceMap to map an instance back to an internal representation. I updated some tests to use public APIs. Other unit tests still reach into internals but now we can find them using ReactInstanceMap. I will do more cleanup in follow ups. The purpose of this diff is to preserve semantics and most of the existing code. This effectively enables support for ES6 classes. All you would need to expose is ReactClassMixin.
Separate React Composite and Class
ReactClass is now composed by ReactCompositeComponent rather than
inherit from it.
The state transition functions currently use ReactInstanceMap to map an
instance back to an internal representation.
I updated some tests to use public APIs. Other unit tests still reach into
internals but now we can find them using ReactInstanceMap.
I will do more cleanup in follow ups. The purpose of this diff is to
preserve semantics and most of the existing code.
This effectively enables support for ES6 classes. All you would need to
expose is ReactClassMixin.