【发布时间】:2017-04-25 01:14:20
【问题描述】:
以这段代码为例:
class Wizard extends Component {
constructor(props) {
super(props);
this.state = {
steps: this.props.children ? this.props.children.length : null
}
}
componentWillMount() {
if (this.state.steps === null) {
throw new Error(
"The <Wizard /> component requires <Step /> components as children"
);
}
}
}
这应该是什么类型的错误?我觉得应该有一个RequirementError,但我从来没有听说过。
【问题讨论】:
标签: javascript reactjs error-handling