How to fix Eslint error "prefer-destructuring"?
Solution 1:
change your code from:
const local = this.props.local;
to:
const { local } = this.props;
They are equivalent and you can call local.foo()
in the same way. except that the second use object destructuring.
Solution 2:
It's a new construct in ES 6 that allows you to match property of an object in assignment. The syntax you need is:
const { local: loc } = this.props
which translates to: "declare a constant loc and assign it the value of property local from this.props".
Solution 3:
It's telling you to use
const {props: {local: loc}} = this;