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 trialTyrique Daniel
10,270 PointsHello I am creating the scoreboard app with React.
Everything works fine until I add the initial players.map arrow function step is implemented on line 52 (Players List comment). The scoreboard is supposed to show the name values under it using the player's array everything shows up when I inspect the element with dev tools until this step maybe it is something I am not catching watched the video 5x. https://teamtreehouse.com/library/iterating-and-rendering-with-map
const players = [ { name: "Guil", score: 50 }, { name: "Treasure", score: 85 }, { name: "Ashley", score: 95 }, { name: "James", score: 80 } ]; const Header = (props) => { return( <header> <h1>{props.title}</h1> <span className="stats">Player: {props.totalPlayers} </span> </header> ); }
const Player = (props) => { return( <div className="player"> <span className="player-name"> {props.name} </span> <Counter score={props.score} /> </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 = (props) =>{
return(
<div className="scoreboard">
<Header title="Scoreboard" totalPlayers={"1"}/>
// {Players List*/}
{props.initialPlayers.map( player =>
<Player
name={player.name}
score={player.score}
/>
)}
<Player name="Tyrique" score={20} />
<Player name="Tyrique" score={30} />
<Player name="Tyrique" score={10} />
<Player name="Tyrique" score={15} />
</div> ); }
ReactDOM.render( <App initialPlayers={players} />, document.getElementById('root') );