Outils pour utilisateurs

Outils du site


dev:reacttableau

fonction map() (fléchée = plug de babel)

Boucle sur un tableau :

 {this.state.clients.map((client) => (
          <li>
            {client.nom} <button>X</button>
          </li>
        ))}

slice()

Copie du tableau original

 const clients = this.state.clients.slice();  
 

push()

Ajoute un champ au tabelau

handleclick = () ⇒ {

  const clients = this.state.clients.slice(); 
  clients.push({id:4, nom: 'tete'});
  this.setState({clients:clients})
};

splice

  • supprime un chanmp du tableau :

clients.splice(index, 1);

dev/reacttableau.txt · Dernière modification : 2021/12/28 13:35 de sbestel