M
M
maksmaksimovich2018-08-27 01:23:29
JavaScript
maksmaksimovich, 2018-08-27 01:23:29

What are mixins for in react?

What are mixins used in react for (I don’t quite understand what they are at all, could you explain in a nutshell?) and what is the alternative for them? It seems like they are no longer in classes, so what is used in classes instead of mixins then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-08-27
@maksmaksimovich

A mixin is an impurity.
For example, if you had a "coffee" component, you added the "milk" mixin to it - you got "coffee with milk".
And if you add mixin "milk" and boil it (or whatever the process is going on) - you get a cappuccino.
That is, you have achieved similar effects for two different coffees (components, types) using the same type of mixin (milk). The example may not be the best, but I think it's understandable. A mixin is a set of additional logic.
What's in classes instead of mixins? Think HOC (Higher Order Component)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question