← React Beginner Questions - Set 8 Q72

What are higher-order components (HOCs) in React?

React Beginner Questions - Set 8

Example

const withLogger = (Wrapped) => (props) => {
  useEffect(() => console.log('mounted', Wrapped.name), []);
  return <Wrapped {...props} />;
};

const LoggedList = withLogger(List);

What to notice

← Back to the question list