Outils pour utilisateurs

Outils du site


dev:reactdiver

Ceci est une ancienne révision du document !


Appel fonction sur bouton

handleclick() {console.log("kjhdfskhsd");}
<button onClick={this.handleclick}>Cliquez moi</button>

THIS

avec BIND

chandleclick() { console.log("this.state");  }
<button onClick={this.handleclick.bind(this)}>Cliquez moi</button>

avec zero fonction (plug de babel)

chandleclick() { console.log("this.state");  }
<button onClick={ () => this.handleclick()}>Cliquez moi</button>

avec fonction fléchée (plug de babel)

 chandleclick = () => { console.log(this.state);}

 <button onClick={this.handleclick}>Cliquez moi</button>
      
    
dev/reactdiver.1640697104.txt.gz · Dernière modification : 2021/12/28 13:11 de sbestel