What's the difference between "()=>()" and"()=>{}" in an anonymous function?

In this case, when I use “(state) => {return {count:state.count+1}}”, it turns out wrong, and when I use “(state) => ({count:state.count+1})” it turns out right, but sometimes in another case, it works well, what happened, anyone can help me with this?

Please post your actual code instead of a picture. Thanks.

() => {} is used to enclose the statements of a function just like in a regular function.

() => () is used when you need to pass a single object from a function as its return value.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.