In the CodeyOverflow forum code, i.e. https://www.codecademy.com/courses/learn-react-introduction/projects/codey-overflow-forum , when I am putting the curly braces within the map statement on comments (Array of objects) in App.js file, I was unable to get the output. But as soon as I removed the braces, it worked fine. Below is the code with curly braces after => :
{
comments.map(comment => {
}
)
}
As far as I am concerned , the code should have run with braces inside also. Please help.
I also can’t understand your code in the form provided - however, as I also got a bit confused with this exercise, I’ve posted my code above and my understanding of what the {} and ‘()’ do below, just in case that is of any help!
The ‘(’ after ‘return’ starts a multi-line JSX expression. The { before comments.map then injects JavaScript within the JSX. Then () around <Card commentObject={comment}/> returns back to JSX within our injected JavaScript. Within that we use {} around comment because we’re injecting JavaScript within that JSX to insert the value of comment into the JSX.