FAQ: Stateless Components From Stateful Components - Build a Stateless Component Class


#1

This community-built FAQ covers the “Build a Stateless Component Class” exercise from the lesson “Stateless Components From Stateful Components”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn ReactJS: Part II

FAQs on the exercise Build a Stateless Component Class

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


#2

Hi guys,
I would like to recommend one important thing in the exercise #2, what you have is this:

Child is going to receive a prop called name , and display that prop on the screen.
How can you make a component display a prop called name ?

  • To access a prop , use the expression this.props.name-of-prop .

Now, looking at this.props.name-of-prop I remember that properties containing a dash can’t be accessed via the dot notation, so, why don’t you change this and actually say:

Child is going to receive a prop called name , and display that prop on the screen.
How can you make a component display a prop called name ?

  • To access a prop , use the expression this.props.nameOfProp or this.props['name-of-prop'] .

So, it’s less confusing for newbies.
Regards,
Victor