Misha Moroshko Misha Moroshko - 8 months ago 22
React JSX Question

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

When is it important to pass

, and why?

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


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.