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,462 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,757 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!