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

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,556 Points

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