Skip to content
loading...

re: Explain Higher Order Component(HOC) in React.js like I'm five VIEW POST

FULL DISCUSSION
 

ELI5
I (your teacher) sees that you are a curious one. I first answer what components are. Components are sheets of paper, anything you see around that is Paper is also a component.

I point you towards a printer and say this is an HOC sweetie, go ahead use it. You being a smart 5 year old know how to use a printer. I explain further to the class.

  • Paper is a component.
  • Printer is an HOC.
  • I ask you to bring me your component (Paper). You bring a nice clean A4 sheet of Component and put it in the HOC (printer).
  • The class eagerly waits to see the output of the HOC.

Alex exclaims, "It is still a Component, but it is so much more cuter!"

  • This new component has her favourite cartoon character printed on it.
  • You and everyone in the class start finding out various other HOC's in the real world.
  • You and your best friend figure out a Pencil, A shredder, an Eraser are all HOCs.
  • With this great day at school you happily head back to home.
 

I love that you used my son's name! :) Thanks!

code of conduct - report abuse