Take a look on "this.state.winners":
import React, { Component } from "react";
const playingPlayers = [
{uid: 1, name: 'John'},
{uid: 2, name: 'Emperor'},
{uid: 3, name: 'King'}
];
class Queue extends Component {
constructor(props) {
super(props);
this.state = {
winners: this.props.winners // here is winner players
}
}
addPlayer(player){
return (
<div>
<li>{player.name}</li>
</div>
);
}
render(){
return (
<React.Fragment>
{playingPlayers.map(player => this.addPlayer(player))}
</React.Fragment>
);
}
}
export default Queue;
Example results:
John
Emperor
King
uid 2 and uid 3 is winner on my array (this.props.winners)
Now, for example, I would like to mark or highlight uid 2 and 3 in the list above.
For example, like this result:
John
Emperor (is winner)
King (is winner)
How can i do ? how can mark this winners without rebuilding list ?
Also you can see my example in here: