我有以下代码。该代码抱怨Use object destructuring.eslint(prefer-destructuring)
,如红色标记中的图像所示。我该如何解决这个问题?我在这里看看,但是https://eslint.org/docs/rules/prefer-destructuring不确定我在哪里做错了吗?
GET_GEOCODE_FROM_ZIPCODE(state, action) {
const { res } = action;
if (res && res.address && res.zipcode) {
const zipcode = res.zipcode;
const address = res.address;
return {
...state,
geoCode: {...action.res, address},
zipcode,
showCallout: true
}
}
return state
}
答案 0 :(得分:0)
您必须destructure
您的对象:
const { address, zipcode } = res;
答案 1 :(得分:0)