Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed React Components!
You have completed React Components!
Preview
In this video, we'll refactor the Counter's event handlers, and implement new props in the Player and Counter components that will act as callback functions.
Resources
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
But in doing so, we lost a functionality
of the Counter component.
0:00
The buttons no longer
modified the score state.
0:02
Counter needs to alter a piece of state
that lives way above it in the main App
0:05
component.
0:10
We learned about React's
unidirectional data flow.
0:12
So if data flows down,
how can a child component
0:15
like Counter get information back
up to its ancestor component?
0:19
To do that, the parent can pass
down a callback function as a prop.
0:25
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up