Declarations differ in how functions are written and contextfrom this,
In the first syntax
bar = () => {
console.log("bar")
}
a function is written using Arrow functionsyntax.
The arrow function does not have its own this; The value thisused is the enclosed version context. Therefore, the keyword thisinside this function will refer to the contextReact class
However second announcement
baz() {
console.log("baz")
}
- , this keyword .
, / React, this.state this.setState, ( - ( )), , this , . , , this this.setState - .
React