React, why use super (props) inside the constructor of the ES6 class?

I understand that the super keyword can be used to call functions in the parent component. However, I don’t quite understand why you would use the super keyword in the example below - just passing it, regardless of whether the details are passed to the constructor.

Can someone shed light on the various reasons for using the super keyword in the constructor of the ES6 class, in response?

constructor(props) { super(props); this.state = { course: Object.assign({}, this.props.course), errors: { } }; this.updateCourseState = this.updateCourseState.bind(this); } 
+7
super ecmascript-6 reactjs
source share
1 answer

super allows you to access the constructor method of the parent class. The only reason to enable props is to access this.props inside your constructor.

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

+21
source share

All Articles