1
拿这个存根作为一个例子:这是什么类型的错误?
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,但我从来没有听说过。
我引你编辑我的问题。尽管如此,我对库/框架不可知的答案真的很感兴趣。 –
框架agnostically我会认为它是一个ChildType错误,只是觉得最合适的,因为孩子只是一个儿童对象的数组和ChildrenType是3个字符长:(我编辑我的答案,以反映这 –
好吧,这将是一个自定义错误类型,我并不想成为一个痛苦,但我正在寻找更高层次的答案,我认为我在我的例子中过于具体,那是我的错, –