FAQ: Child Components Update Their Parents' state - Receive the Event Handler


This community-built FAQ covers the “Receive the Event Handler” exercise from the lesson “Child Components Update Their Parents’ state”.

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

Web Development

Learn ReactJS: Part II

FAQs on the exercise Receive the Event Handler

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!


Why would we define changeName in the parent class instead of baking the functionality into the child? is it so that we can update the parent component?


because the child component is stateless. Its a design pattern, data flows one way (from parent to child).

A React component should use state to store information that the component itself can change, however, if every component has there own state, you will loose overview pretty quickly (if you have a couple dozen components). And your code would be really difficult to maintain and change.

lets say you build an application with react, If your application gets big enough, it would be wise to use redux to manage the state of your application in a single place.

this is always the problem (problem, not your fault :wink: ) with the kind of question you just asked. These design patterns start really to pay off when your application gets bigger, not when you have two components like in the lesson.