Design Patterns · Middle · Question 37 of 75
What's wrong with mixins (Object.assign(Class.prototype, mixin))?
- ✓Correct answer: Implicit dependencies, name clashes, unclear origin of methods
- 2Mixins are forbidden in strict mode and don't work in modules
- 3Mixins copy only methods, not properties
Explanation
Methods "appear" in the class from who knows where, and mixins can overwrite each other and rely on each other's fields. React dropped mixins back in the class component era; today hooks and composition solve the same problem.