ref – https://stackoverflow.com/questions/30571875/whats-the-difference-between-super-and-superprops-in-react-when-using-e
There is only one reason when one needs to pass props to super(): When you want to access this.props in constructor.
Passing:
1 2 3 4 5 6 7 8 |
class MyComponent extends React.Component { constructor(props) { super(props) console.log(this.props) // -> { icon: 'home', … } } } |
Not passing:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class MyComponent extends React.Component { constructor(props) { super() console.log(this.props) // -> undefined // Props parameter is still available console.log(props) // -> { icon: 'home', … } } render() { // No difference outside constructor console.log(this.props) // -> { icon: 'home', … } } } |
Note that passing or not passing props to super has no effect on later uses of this.props outside constructor.
That is render, shouldComponentUpdate, or event handlers always have access to it.