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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Otto linden](https://secure.gravatar.com/avatar/d7f9c70c933963420fa171c72cb49876?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Otto linden
5,857 PointsCan't you just do score={50} once?
Hello! Why do you need to do the score={}twice? once in the app, player and once in the player? cant you just do it in player? :) My code:
const Header = (props) => {
return (
<header>
<h1>{props.title}</h1>
<span className="stats">Players: { props.totalPlayers }</span>
</header>
);
}
const Player = (props) => {
return (
<div className="player">
<span className="player-name">
{ props.name }
</span>
<Counter score={35}/>
</div>
);
}
const Counter = (props) => {
return (
<div className="counter">
<button className="counter-action decrement"> - </button>
<span className="counter-score">{ props.score }</span>
<button className="counter-action increment"> + </button>
</div>
);
}
const App = () => {
return (
<div className="scoreboard">
<Header title="scoreboard" totalPlayers={1} />
{/* Players list */}
<Player name="Guil" />
</div>
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
3 Answers
![JS Goupil](https://secure.gravatar.com/avatar/cada713637171815d666c45f9284fe6d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
JS Goupil
11,309 PointsI know this question is kinda old, but just for the sake of others that might be reading this, you are correct. If we add more players to the app, and the score is hard coded in the Player component, all players added will have the same score. So now instead of hardcoding it in the player, we can set it individually for each player component that is added. Hope that helps :)
![Otto linden](https://secure.gravatar.com/avatar/d7f9c70c933963420fa171c72cb49876?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Otto linden
5,857 Pointsis ti because we add more people to the app?
![Magnus Martin](https://uploads.teamtreehouse.com/production/profile-photos/2809542/micro_IMG_20190605_153652.jpg)
Magnus Martin
44,123 PointsHi Otto,
I suggest the Player component used in the App component is responsible for setting the initial counter value via attributes. The Counter component within the Player component just receives the counter value through props.