
Jessica 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
Pro 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,142 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,142 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!