Mixins

Components are great to achieve reusability, but what if different components in different domains share the same behavior?

We do not want duplicated code in our applications, and React gives us a tool that we can use when we want to share functionalities across various components: mixins.

Using mixins is no longer recommended, but it is worth understanding the problems they tried to solve and see what the possible alternative solutions are.

Also, it could happen that you might have to work on a legacy project that uses an older version of React, and it makes sense to know what mixins are and how to deal with them.

First of all, mixins work only with the createClass factory, so if you are using classes, you cannot use mixins, and that is one ...

Get React Design Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.