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 trial

JavaScript React Components Data Flow Update State Based on a Player's Id

why isnt this is {}

const id = props.id;

why is props.id not in {}

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

Hi @Ericka Erickson, your question isn't very clear, are you asking why does the property id not exist on the props 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.

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Data Analysis Techdegree Graduate 49,443 Points

Hey Ericka Erickson ! :wave:

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 :smiley: :thumbsup:

yes this helps! thank you