Question · JavaScript and React course · Module 15: Patterns and Architecture

Composition in React

Why does React prefer composition over inheritance?

Answer options

  • React uses exclusively functional programming and does not support objects
  • Composition requires less memory than inheritance in the browser
  • Inheritance is faster, but React does not support classes
  • Composition allows flexible combining of independent components without a rigid hierarchy

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