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

Polymorphic Prop as

What does the 'as' prop enable in polymorphic components, e.g., <SpaceButton as="a" href="/link">?

Answer options

  • Automatically adding target='_blank' attribute to every element
  • The consumer decides which element or component (button, a, div, Link) the component renders as
  • Changing the component name in React DevTools to the value of the 'as' prop
  • Automatically converting the component from functional to class-based

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