[英]destructuring error despite correct destructuring (eslint)
我有一堂課:
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;
}
}
為簡便起見,未添加構造函數。
盡管破壞了道具,但我仍然收到eslint錯誤,說Muse use destructuring props assignment
。 我相信我已正確執行此操作,並針對AirBnB eslint配置進行了仔細檢查,但錯誤仍然存在。
我如何擺脫錯誤(修復錯誤,而不是制定規則忽略該錯誤)。
無需從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.