super()
super(props)
When you want to access this.props in constructor() then you should pass props to super() method.
this.props
constructor()
Using super(props):
class MyComponent extends React.Component { constructor(props) { super(props) console.log(this.props) // { name: 'John', ... } } }
Using super():
class MyComponent extends React.Component { constructor(props) { super() console.log(this.props) // undefined } }
Outside constructor() both will display same value for this.props.