React: Building Modern Web Applications
by Jonathan Hayward, Artemij Fedosejev, Narayan Prusty, Adam Horton, Ryan Vice, Ethan Holmes, Tom Bray
Mixins
mixins is a React feature that allows you to share cross cutting concerns with components. A mixin is simply an Object Literal that is used to add behavior to a component. It's an implementation of the decorator pattern and the mixin you create can provide implementations of React's component lifecycle events (componentWillMount, componentDidMount, and so on) and those will be called during your component's lifecycle along with the component's lifecycle methods.
Note
Here are the details from React's documentation:
A nice feature of mixins is that if a component is using multiple mixins and several mixins define the same lifecycle method (i.e. several mixins want to do some cleanup when the component is destroyed), all of the lifecycle methods ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access