Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript React Basics (retired) Thinking in Components Decomposing our Application

Why do we need the title key on both the header and application components?

Same for the counter and player components. Would there be something wrong with adding just the score key to counter and the title key to header?

D P
D P
3,503 Points

Short answer is that the containing component is passing the title information to the component within.

I think it just boils down to how you want to structure your app. Personally, I like the the way it is in the video because it makes sense to give the title to the scoreboard when you instantiate the Application component. If the app grew to contain more than just a scoreboard I think giving the title straight to the header would make sense (or at least giving it a more specific property name like 'scoreboard-title').

I do think that in any case it makes more sense to keep the score with the Player component because that data is strongly related. I'm not even sure how you'd approach separating them out. You wouldn't want to have just the score free-floating somewhere else in the app.