-
Notifications
You must be signed in to change notification settings - Fork 226
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
[addons-react] Update FluxibleMixin to check for autobind:false #316
Comments
@mridgway thoughts? We can avoid having users do the current workaround: componentWillMount: function () {
this.onChange = this.onChange.bind(this);
} |
Sure, I'm fine with this. |
The |
Edit: This is a bad approach because it's private and might have changed in React 15. |
@mridgway and I discussed this, and came up with some options. I think the simplest might be to just set the context to
If we think the above could lead to BC breakage, we could always try to detect this pattern by updating getHandler: function (handler) {
if ('string' === typeof handler) {
handler = this[handler];
}
if (!handler) {
throw new Error('storeListener attempted to add undefined handler. Make sure handlers actually exist.');
}
// Bind the handler to the component instance. This protects againsts:
// `autobind: false` causing `onChange` to be called with the wrong context.
if (handler === Object.getPrototypeOf(this).handler) {
handler = handler.bind(this);
}
return handler;
}, |
Closing as mixins are being deprecated. |
If set to false, then manually bind the onChange handler.
https://github.com/yahoo/fluxible/blob/master/packages/fluxible-addons-react/FluxibleMixin.js#L116
The text was updated successfully, but these errors were encountered: