I am trying to understand the below syntax in my React app. Essentially I wanted to understand the code inside setState()
this.getSomePromise().then(
// resolve callback function
someImg =>
this.setState(prevState => ({
...prevState,
doggo: someImg.message
})),
// reject callback function
() => alert("Rejected!")
);
What I was expecting was a syntax like this;
this.setState(prevState => {
// some code
})
But the round bracket immediately after prevState =>
is getting me confused.