Misha Moroshko Misha Moroshko - 3 months ago 9
React JSX Question

What's the difference between "super()" and "super(props)" in React when using es6 classes?

When is it important to pass

props
to
super()
, and why?

class MyComponent extends React.Component {
constructor(props) {
super(); // or super(props) ?
}
}

Answer

There is only one reason when one needs to pass props to super():

When you want to access this.props in constructor.

(Which is probably redundant since you already have a reference to it.)

This is explicitly said in one Ben Alpert's answer to similar question.