-
Notifications
You must be signed in to change notification settings - Fork 47
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
Doesn't work with decorator #45
Comments
Does it work when you put the react-mixin decorator under the withStyles? @withStyles(s)
@reactMixin.decorate(LinkedStateMixin)
class LoginPage extends Component { |
Have the same issue. This is because when any code executes, its context doesn't match the class. Here, I suppose, must be a bind statement, that will explicitly set the context to decorated functions. |
@Lonelind can you try to create a minimal repro case? |
Sure. For example, we could get a Lifecycle mixin form react-router v1.x (in 2.x mixins are deprecated). That's what I faced: import React from 'react';
import { decorate as mixin } from 'react-mixin';
import { Lifecycle } from 'react-router';
@mixin(Lifecycle)
export default class RouteComponent extends React.Component {
routerWillLeave(nextRoute) {
console.log(this.state, this); // 'this' will be an anonymous function
}
render() {
/* ... */
}
}
|
So the lack of autobinding in react-mixin strikes again... it's in the readme that it's not supported, but maybe it's time to support it. |
I have the following code:
The react-mixin functionality works as intended without a decorator, however, when a decorator is included I get the error "this.linkState is not a function'
The text was updated successfully, but these errors were encountered: