FAQ: Child Components Update Their Parents' state - Automatic Binding


#1

This community-built FAQ covers the “Automatic Binding” 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 Automatic Binding

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

So basically, in the end, the changeName(newName) method was just a waste? because it is not being used in the Child component anymore. The Child component has its own Eventhandler now.


#3

And as far as i knew, only the Stateful components are supposed to have a constructor() and super(). But the Child component is not a Stateful component so how come does it have a constructor?


#4

its still used, but its in parent.js now. This design pattern to make sense to have all your state in a single place, instead of each individual component. You currently have only two components, but this could very easy become a dozen or even hundred(s) in a medium/large project. Then you don’t want each component having there own state, you will loose the overview in no time.

where did you read this? The only thing a stateless component can’t have are states.


#5

Oh, that clarifies everything. Thanks.