June 23, 2020
What is the purpose of using super constructor with props argument?
A child class constructor cannot make use of this
reference until super()
method has been called. The same applies for ES6 sub-classes as well. The main reason of passing props parameter to super()
call is to access this.props
in your child constructors.
Passing props:
Not passing props:
The above code snippets reveals that this.props
is different only within the constructor. It would be the same outside the constructor.