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

Cannot read property 'name' of undefined

I've triple checked everything but I'm getting an error of Cannot read property 'name' of undefined in Scoreboard.js:

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

Any idea what's going wrong, or how I can debug it?

1 Answer

Whoops! Figured it out. I was missing

            return player;

from the player.js reducer on the case of UPDATE_PLAYER_SCORE

That's what I get for listening to Guil at 1.75x speed!

Olga Isakova
Olga Isakova
5,349 Points

Thanks a lot for the follow up, Jack Jackson, you just saved me from an excruciating debugging session:)

Danielle Quevedo
Danielle Quevedo
17,935 Points

Yeah, ditto -- thanks for posting, Jack Jackson -- I did the exact same thing. You saved me some trouble.