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 React Basics Introducing Props Iterating and Rendering with map()

Micah Cleveland
Micah Cleveland
630 Points

Question answered later on in the video.

App Updated Code:

const App = (props) => { return ( <div className="scoreboard"> <Header title="Scoreboard" totalPlayers={3} />

        { props.initialPlayers.map( playerObj =>  
            <Player 
                name={playerObj.name} 
                score={playerObj.score} 
            />
        )}
    </div>
);

}

Note: copied the list of players from teachers notes assigning them to a constant variable and using square brackets.

Full Error: react_devtools_backend.js:4026 Warning: Each child in a list should have a unique "key" prop.

Check the render method of App. See https://fb.me/react-warning-keys for more information. in Player (created by App) in App

Mark Sebeck
Mark Sebeck
Treehouse Moderator 32,410 Points

Great job figuring it out and thanks for updating the question. Will be great for other students with the same question. I marked your answer Best for you

2 Answers

Micah Cleveland
Micah Cleveland
630 Points

This was just a warning however I was curious. I was able to get rid of the warning by adding a key attribute w/ unique value to the <Player /> element.