-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Get rid of mixins #2437
Comments
So the problem I see with this is the fact the mixin sets the propTypes as well as introduces other methods to the instance. A possible solution would just be to move the methods into a helper class and then add the propType it adds directly to the propTypes in the parent component. |
Another potential solution is making the mixins Decorators, and instead of adding the |
And a third potential solution is to just use |
Adding the fact that we are working on another branch. |
Ah, my bad. I've got a one track mind at times 😛 |
My current PR uses the third technique. It doesn't exactly get rid of mixins but it does solve the problem of using them with ES6 classes. |
@BobertForever I kinda have an anti-pattern-phobia. I dislike mixins and love composition, orthogonality, and conventions. A subset of utility methods, HOCs and stuff will easily solve this issue. it's only a matter spending time and actually making it a reality. But I value productivity more than my opinions. Iterations and getting things done will teach your lessons beyond anything you can learn with just conversations. I propose this: You go on ahead and migrate the classes the fastest way possible (I think that would be I truly appreciate the time you spent making this wish a reality. Thanks a lot 👍 👍 |
I agree about getting rid of mixins and I think your point with utility methods would be good (since a large portion of the mixin is just providing utility around the thing it added to the props). Looking through the mixins though I see a lot of them which rely heavily on the React methods, so moving them out to Utility methods would likely mean everywhere they were used, the class would have to implement those React methods and add in I guess potentially you could extend what used to be a mixin? Though that was brought up last time this conversation was had and doesn't really work when a class has multiple mixins. |
So I ran into an issue with that library I was using, which I explain in PR #2451, and propose a temporary solution. It's basically my second suggestion from above, creating a custom decorator for what used to be a mixin. |
Almost... 😍 |
This issue should have been closed ages ago. We do no longer use mixins 🎉 . |
Right now, mixins are inhibiting a clean migration to es6 components (though a workaround exists with Decorators). Finding a way to get rid of them, or modify them so they don't need to be mixins, would be good.
This came up in conversation on #458.
Edit by @newoga
The text was updated successfully, but these errors were encountered: