Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMrwan Grada
753 Pointswhat kinda function is this : const MapStateToProps = state => ()
what kinda function is this : const MapStateToProps = state => () why does it end with a PARENTHESIS instead of brace?
1 Answer
Steven Parker
231,269 PointsAs Vince's examples show, one form of function definition would have a function body in braces. Another form has a single expression which is returned.
The parentheses after the "fat arrow" make it clear that the second form is being used. This is particularly useful when the return value happens to be a literal object (as in Vince's examples). Otherwise, the braces might be misinterpreted as being part of the first form without them and cause an error.
Vince Brown
16,249 PointsVince Brown
16,249 PointsMrwan, It is just a regular arrow function but is using the shorthand syntax for return
since mapStateToProps is suppose to return an object instead of
You can write it like this