Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript React Basics Understanding State Understanding State Review

Brian Godden
Brian Godden
4,649 Points

React Basics, last quiz on the course "Understanding State"

I this quiz, I was certain the answer to the code completion for displaying a prop named time would be this.props.time (since Clock is a component Class). I thought I understood this, but the quiz tells me I'm incorrect. Can someone help me understand what I'm doing wrong for that answer?

Thanks! -Brian

3 Answers

Torben Korb
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Torben Korb
Front End Web Development Techdegree Graduate 88,492 Points

Hi Brian,

you are absolutely right and this.props.time is correct.... BUT you have to wrap this variable with curly braces to get the output in your component return value. If not you only output "this.props.time" as a simple string.

So the correct answer is {this.props.time}

Hope this help for understanding. Happy coding!

Rich Donnellan
MOD
Rich Donnellan
Treehouse Moderator 25,764 Points

Hey Brian!

You're not misunderstanding as this is exactly how you would access the props in a component class. Did you put the curly braces around your answer ({this.props.time})? I was able to submit the answer successfully.

Brian Godden
Brian Godden
4,649 Points

Ah... Yep, that's it. My eyes were just simply unable to see the difference. :)

Thank you!