What is the difference between super() and super(props) in React using ES6 classes?

  • There is no difference, they both call the superclass constructor
  • super() calls the superclass constructor, while super(props) passes props to the constructor
  • super() is only used in functional components
  • super(props) calls the superclass constructor, while super() passes props to the constructor
In React using ES6 classes, "super()" is used to call the constructor of the superclass, while "super(props)" is used to pass props to the constructor of the superclass. The "super(props)" syntax is necessary if you need to access props in the constructor of a subclass.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *