Managing State and Data Flow
Update State Based on a Player's Index
where does the index get set?
this.state.players.map( (player) =>
this.state.players.map( (player, index) =>
Take a look at the map documentation here:
Daniel Nakonieczny Greate answer. It's a shame that the answer is posted as a comment, I cannot give an upvote. Thanks.
I believe the map function takes an optional index parameter corresponding to the index of the array it is mapping. So the players array has an implicit index based on its position in the array, which is then passed down.
The index is the position of the player in the array. (I.e Guil's index is 0 because it is the first item in the array. )
Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.