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



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

Answer / Mayank Dwivedi

In a constructor of a React component using ES6 classes, calling super() alone passes the props to the parent class, whereas calling super(props) explicitly passes the props to the parent class. It's recommended to use the latter to avoid potential issues with default props.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More React.js Interview Questions

How events are different in react?

1 Answers  


What is low-level component lifecycle in react.js?

1 Answers  


Show how the data flows through redux?

1 Answers  


What is the use of ‘prop-types’ library?

1 Answers  


What are the methods called when state or props of the component is changed?

1 Answers  


Is setState() is async? Why is setState() in React Async instead of Sync?

1 Answers  


Why vue js is better than react?

1 Answers  


What is one of the core types in react?

1 Answers  


What is the recommended way for naming components?

1 Answers  


Enlist the advantages and disadvantages of reactjs?

1 Answers  


Explain the components of Redux?

1 Answers  


Why should I use react js?

1 Answers  


Categories