higher-order component
A function that takes a component and returns a new component wrapping it with extra props or behaviour.
In more detail
HOCs, written like withUser(Profile), were a common way to share logic before hooks. They add wrapper layers to the tree, can overwrite props with the same name and hide where a prop comes from, so custom hooks usually replace them today.
Related terms
- render prop — A prop whose value is a function the component calls to decide what to display, passing in its internal data.
- custom hook — Your own function whose name starts with use and that calls other hooks, packaging stateful logic so several components can reuse it.
- prop collision — When two wrappers or a wrapper and its caller use the same prop name, so one silently overwrites the other.
- wrapper hell — A component tree buried under many layers of wrapper components added by higher-order components and render props.
Taught in
- Compound Components: Inversion of Control with Context — React 19 & Modern Component Architecture
- Higher-Order Components And Render Props: Tradeoff Analysis — React 19 & Modern Component Architecture