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 trialJessica Graham
6,878 PointsWhen you're doing a return within the 'getDefaultProps' function, why does it uses curly braces {}
whereas in the 'render' function it uses brackets ()?
2 Answers
Alex Warner
Courses Plus Student 4,987 PointsMy best guess is the value being returned by the getDefaultProps method (aka function) is a javascript object which is always enclosed in curly braces for example {myName: "Alex", myCity: "Los Angeles"}. The render method returns an html string which can be contained in parens ()
Sameer Dewan
Courses Plus Student 13,145 Pointswhen you put things in (....) written like return (...), you're returning whatever is in there
meaning, if you can follow my poor writing,
you could write return {....} as return ( {.... } )
it just depends on what the specific function expects returned that will cause the minor differences in syntax!
Sameer Dewan
Courses Plus Student 13,145 PointsIn this specific example, the function for getDefaultProps is written to accept an object full of keys, the keys being the default properties you're getting
edit: also, those aren't brackets, they are paranthesis lols! Just sayin'. Brackets are what we write arrays with [....... ]
Jessica Graham
6,878 PointsJessica Graham
6,878 PointsMakes sense. Thanks!