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

Micah Cleveland
Micah Cleveland
633 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 38,004 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
633 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.