-
Notifications
You must be signed in to change notification settings - Fork 2.5k
The :: bind operator probably won't be going forward #539
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
Comments
Thanks for pointing this out. It makes me a bit sad, but my IDE never really liked it, so my code might actually be "green" now. The |
There's another way of getting around the common use case of
|
Arrows to the rescue! |
The arrow is a good idea. That still works with super, correct? Also, this solves a problem with unbinding listeners. This returns false: meaning you can't un-attach bound listeners easily. |
After testing, you can't call super with the arrow approach. Babel reports unexpected super. Classes really should have been spec`ed to be bound by default. 😬 |
IMHO, you shouldn't be using OO inheritance at all in React, so |
@quicksnap i've been using the same technique! one thing in your code snippet just wanted to point out click handler would have to be a class method to be invoked using class MyThing extends Component {
boundHandler = () => this.isBound();
render() { return <button onClick={this.boundHandler} /> }
} |
Hey guys,
From the looks of things, the bind operator won't be going forward.
I'm currently using this little helper:
Not sure if this is the best way to do it, but it's a decorator that binds all methods that begin with an
_
, removing the_
for the bound method. It may be better to just add abindHandlers
function to the prototype.Do think the project should still use the bind operator or switch to an auto-binding option?
The text was updated successfully, but these errors were encountered: