jeudi 8 mars 2018

React Looping Component except one element

I want to loop a list of elements except the first which is an Alert

example

const selection = (player, matchId, key) => (
    <ul>
      <li key={key}>1</li>
    </ul>
);

 return (
    <div>
       {(match.live) ? <li><Alert>This is an alert</Alert></li> && match.players.map((player, ix) => (
          selection(player, match.matchId, ix)
          )) : null}
    </div>

How can i exclude the Alert from the loop, at the moment i am passing the key to the list elements but the Alert is repeating too

Aucun commentaire:

Enregistrer un commentaire