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

How does the program know the it's connected to var PLAYERS?

When we write:

{props.players.map(function(player) { return <Player name={player.name} score={player.score} key={player.id} /> })}

How does the program know that it has to extract all the properties from the array PLAYERS? We are not indicating anywhere that it's connected apart from here. And if this is the reason, still don't understand the connection

ReactDOM.render(<App players={Players} />, document.getElementById('container'));

3 Answers

That attribute looking thing in the ReactDOM.render line of code players={Players} is passing in the Players array as the players prop. You can then see it accessed via props.players in the component code.

Does that help? It's hard to explain much more without seeing the rest of the code or a link to the video this is related to.

Thank you Iain, then it's how I understood the way it works.

Thank you!!Now I see