2020年12月16日解決済み

関数の渡し方がわかりません

ユーザー

なぜ{count: this.state.count + 1}の場合はreturnは不要で、 {count: prevState.count + 1}の場合はreturnが必要になるのでしょうか?

this.setState({count: this.state.count + 1});
     ↓
this.setState(prevState => {
return {count: prevState.count + 1}
});

以下のように書いてもカウントアップされませんが、何がまずいでしょうか?
this.setState(prevState => {count: prevState.count + 1});

スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?