React · Middle · Question 18 of 75

What is a higher-order component (HOC)?

Explanation

Example: withAuth(Page) checks authentication and renders Page or a redirect. HOCs were popular before hooks. Downsides: "wrapper hell", prop name collisions, complex typing. Today such logic is usually moved into custom hooks.

Further reading

Problem with a question

React · Middle · question 18

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz