我意识到 super 关键字可用于调用父组件中的函数。但是,我不完全清楚为什么要在下面的示例中使用 super 关键字 - 只需将任何传递给构造函数的 props 传递给它。
有人可以解释一下在 ES6 类构造函数中使用 super 关键字的各种原因吗?
constructor(props) {
super(props);
this.state = {
course: Object.assign({}, this.props.course),
errors: { }
};
this.updateCourseState = this.updateCourseState.bind(this);
}