Question · JavaScript and React course · Module 8: Advanced React Patterns

Introduction: HOC and Modifying the Original Component

Should a HOC modify the original component passed as an argument?

Answer options

  • It depends on the component type - class yes, functional no
  • Yes - HOC adds new methods directly to the component
  • Yes - HOC replaces the component's prototype with a new one
  • No - HOC creates a new wrapping component, it doesn't mutate the original

You can check the correct answer by solving this task in the CodeWorlds game.