FAQ: Stateless Components From Stateful Components - Pass a Component's State

Community%20FAQs%20on%20Codecademy%20Exercises

This community-built FAQ covers the "Pass a Component’s State " 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 _Pass a Component’s State _

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!

Is there any difference in usage between state and props?

Why didnt we need to export Child component to be able to use it in Parent?

alright so the way that Im understanding props and state is like this…Props are only the variable passed to a child component by it’s Parent component. So in this lesson…{this.props.name} is that variable. its saying hey…the parent will be passing you a name variable at some point. BUT the state…is the data that the parent holds. thats why you set the state in the parent. I still have questions on this subject too but so far I think im understanding this right,

I’m curious - for what reason would you want to pass props to a stateless component? I couldn’t find any answers online so I’m seeking clarification. Is it due to the ‘Single responsibility’ principle? This way you can separate the components that handle rendering and the components that handle data collection.

This is using class to pass from parent to child, what about hooks, how would you pass from parent hook to child hook page?