[英]destructuring error despite correct destructuring (eslint)
I have a class: 我有一堂课:
export default class DepartmentItem extends React.Component {
render() {
const {
name,
location,
position,
salary,
age,
citizenship,
description
} = this.props.department;
const { link, tag } = this.props.department.url;
const { isToggleOn } = this.state;
}
}
For brevity the constructor is not added. 为简便起见,未添加构造函数。
Despite destructuring the props i still get the eslint error saying Muse use destructuring props assignment
. 尽管破坏了道具,但我仍然收到eslint错误,说
Muse use destructuring props assignment
。 I believe I did this correctly, and double checked against the AirBnB eslint configs, but the error remains. 我相信我已正确执行此操作,并针对AirBnB eslint配置进行了仔细检查,但错误仍然存在。
How did I get rid of the error (fixing it, not making a rule to ignore it). 我如何摆脱错误(修复错误,而不是制定规则忽略该错误)。
Instead of picking from this.props.department
, just nest the destructuring. 无需从
this.props.department
进行选择,只需嵌套解构即可。
const {
department: {
name,
location,
position,
salary,
age,
citizenship,
description,
url: {
link, tag
}
} = this.props;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.