I have a line like this this.report = newVal[0];
. I'm looking at the documentation and I'm confused.
example I have seen are like
const local = this.propslocal
const {local} = this.props
any ideas?
Take a look at this: eslint prefer-destructuring rule :
This rule enforces usage of destructuring instead of accessing a property through a member expression.
As the examples you have seen, you should change your:
this.report = newVal[0]
To this instead:
[this.report] = newVal;
To make it clear for you, if newVal
has 4 items, and you want to store first 2 items into different variables, instead of doing:
const a = newVal[0];
const b = newVal[1];
Using destructuring, you should do:
const [a, b] = newVal;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.