Tag:react.js
Article From:https://segmentfault.com/q/1010000012146960
Question:

Like the meaning of the first picture, shouldn’t it be written below?

Answer 0:

Simple understanding:

 this.setState({
    from,
    till,
});

Equivalent to

 this.setState({
    from:from,
    till:till,
});

Answer 1:

ES6 In the deconstruction assignment of a variableThe deconstruction assignment of an object
http://es6.ruanyifeng.com/#docs/destructuring#The deconstruction assignment of an object

And you can find that it’s actually there.startDate , endDate These variables are.

Learning React recommends that you first be proficient in ES6

Answer 2:

This is ES6’s allowed writing

let startDate = "";
this.setState({
    startDate
});

Amount to

let startDate = "";
this.setState({
    startDate:startDate
});

Similar Posts:

Link of this Article: There’s a question about setState

Leave a Reply

Your email address will not be published. Required fields are marked *