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 Building Applications with React and Redux Putting it all Together Updating the Player, Counter and AddPlayerForm Components

Bruno Carpinelli
Bruno Carpinelli
7,974 Points

Player list is empty.

My list of players is empty. In developer tools, the player props is set to null. Please help me!

No Players Dev Tools

Code: https://github.com/brunogcpinheiro/react-redux-teamtreehouse-course

2 Answers

Nick Bushby
Nick Bushby
20,361 Points

Hi Bruno, I was having the same problem. I noticed in Scoreboard.js the const playerComponents is returning a JSX component, therefore it needs to be wrapped in parentheses.

So instead of:

const playerComponents = players.map((player, index) => {
      <Player
        index={index}
        name={player.name}
        score={player.score}
        key={player.name}
        updatePlayerScore={updatePlayerScore}
        removePlayer={removePlayer}
      />
    })

It should be:

const playerComponents = players.map((player, index) => {
   return (
      <Player
        index={index}
        name={player.name}
        score={player.score}
        key={player.name}
        updatePlayerScore={updatePlayerScore}
        removePlayer={removePlayer}
      />
    )
    })

Alternatively you can omit the return and just replace the { } with ( ) Hope this helps.