Misha Moroshko Misha Moroshko -4 years ago 152
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) ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download