M
M
mixerstyle2018-08-27 12:09:58
JavaScript
mixerstyle, 2018-08-27 12:09:58

How to destructure state in React ESLint?

ESLint says to destructure the selected row, but I don't know how. Tried different methods but not the same apparently. Tell someone how to fix it. Thanks
5b83bf851e034653468193.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-08-27
@mixerstyle

const { id } = this.state;
It is also not clear from the example why you set the data to an array and do destructuring. Such a structure is harder to read and maintain, and creating an array and destructuring, in this case, is an extra operation. It would be more correct like this:

const { id } = this.state;
const newOrder = { id, ... };
const orders = [];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question