This post aims to help those who have worked with and studied React Higher Order Components previously and want a quick brush up on key topics.
At its most basic, what is a react HOC?
A function that accepts a component as an argument and returns a new component
What are you trying to accomplish by using a HOC?
Sharing state and behavior across like components.
What is the name of the component being passing as a function parameter to the HOC?
WrappedComponent. It’s called this because it’s literally wrapped in the HOC.
HOC’s are a means of code reuse in react, what are some other forms of code reuse:
- Components themselves
- React Hooks