我知道可以使用super关键字调用父组件中的函数。然而,我并不完全清楚为什么在下面的示例中要使用super关键字 - 只是将传递给构造函数的任何props直接传递给它。
请问有人可以解释一下在React中使用ES6类构造函数时使用super关键字的各种原因吗?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}
class SpecialDialog extends Dialog {
- Conspicuous Compiler