Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.