This sentence is supposed to explain why super(props) is needed:

"This is because it will allow us to call the constructor of the parent class and initialize itself in case our class extends any other class which has constructor itself."

Can anyone explain this in a way that makes sense? What does it mean for one class to extend another?

1 Answers

Jayce444 On

They're referring to the traditional OOP reason for calling super, which is to call the constructor of the parent class your current one is extending. Your class components will extend React's classes, such as Component or PureComponent.

If you're wondering about super(props)'s place in React specifically, check out the accepted answer in this post.

There's also posts explaining difference between super() and super(props) which you can Google around for.

P.S. Official React docs say to always use super(props) in a constructor.