假设代码如下:
this.props.myFunction();EsLint给出以下错误:
Must use destructuring props assignment react/destructuring-assignment虽然当前的代码是清晰和简洁的,但如果我仍然想要分解代码并让EsLint满意,我该怎么做呢?
发布于 2020-12-13 09:00:45
该规则docs指出,在使用props的属性之前,应该对其进行解构,因此只需这样做:
const { myFunction } = this.props;
myFunction();https://stackoverflow.com/questions/65271449
复制相似问题