This is a very creative analogy, for a person familiar with HOCs I totally get it. I just worry it might have missed an important detail which might not be that obvious to a newcomer.
HOC is not a component but just a mere function which happens to return a component. ๐งค , ๐ข would rather be the output of the HOC.
When we write โwithCompX(compY)โ, we mean this HOC will wrap compY with CompX.
The examples below are similar in logic, the only difference is that one is done real-time and the other is done statically/by hand.
// by hand, not so cool ๐
const MyComp = (
<CompX>
<CompY/>
</CompX>
);
const withX = (Comp) =>
<CompX>
<Comp/>
</CompX>;
const MyOtherComp = withX(CompY)
// MyComp and MyOtherComp are now same with the only difference is that MyOtherComp was generated on the fly
I see where my analogy breaks down as I was using each object(gloves, helmet, etc) as a concrete component, not as something that enables Tony to do something.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is a very creative analogy, for a person familiar with HOCs I totally get it. I just worry it might have missed an important detail which might not be that obvious to a newcomer.
HOC is not a component but just a mere function which happens to return a component. ๐งค , ๐ข would rather be the output of the HOC.
When we write โwithCompX(compY)โ, we mean this HOC will wrap compY with CompX.
The examples below are similar in logic, the only difference is that one is done real-time and the other is done statically/by hand.
Thanks Kushan.
I see where my analogy breaks down as I was using each object(gloves, helmet, etc) as a concrete component, not as something that enables Tony to do something.