What is a higher-order component, and have hooks replaced it?

React JSX, components and props · Experienced

Model answer

A higher-order component (HOC) is a function that takes a component and returns a new component with added behaviour, such as withAuth(Page). They were common for sharing logic before hooks.

Custom hooks now handle most of those cases in a simpler way and avoid wrapper nesting. HOCs still appear in older code and some libraries, so you should be able to read them.

Learn this topic

React Components and Props Explained with Examples in the course React.js Full Course: Beginner to Advanced.

Sign in to add your own answer.

More questions