I am learning react nowadays. I understand if I add curly brackets here I can add multiple statements on here but I don't understand why I need parentheses.
class Component extends React.Component {
state = {
count: 0,
};
render() {
return (
<div>
<p>{this.state.count}</p>
<button
onClick={() => {
console.log("clicked");
this.setState((state) => ({
...state,
count: state.count + 1,
}));
}}
> Click
</button>
</div>
However, when I use this.setState, I think this should be right
this.setState((state) => {
...state,
count: state.count + 1,
});
}}
I know what I think is right is actually wrong but cannot understand adding parentheses Could anyone help me with this?