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 trialEricka Erickson
9,982 Pointswhy isnt this is {}
const id = props.id;
why is props.id not in {}
1 Answer
Travis Alstrand
Treehouse Project ReviewerHey Ericka Erickson !
Are you referring to 1:20, inside of Counter.js
?
If so, this is because it's not inside of the return
statement and therefore not a JSX Expression. It's just regular JavaScript here defining the value of a new variable.
If we were trying to display props.id
in the return statement for example, it would need to be in {}
. For example...
return (
<h1>{props.id}</h1>
)
Or...
const id = props.id
return (
<h1>{id}</h1>
)
I hope this makes sense, if you're still having trouble with this topic you can always visit Understanding JSX and Embed JavaScript Expressions in JSX from our React Basics course
Ericka Erickson
9,982 Pointsyes this helps! thank you
Travis Alstrand
Treehouse Project ReviewerAwesome! You're very welcome
Jamie Reardon
Treehouse Project ReviewerJamie Reardon
Treehouse Project ReviewerHi @Ericka Erickson, your question isn't very clear, are you asking why does the property
id
not exist on theprops
object? If so, are you following along with the video's code or your own? It's hard to add further input without having the code related to this.