dev:reactdiver
Ceci est une ancienne révision du document !
Table des matières
Appel fonction sur bouton
handleclick() {console.log("kjhdfskhsd");}
<button onClick={this.handleclick}>Cliquez moi</button>
THIS
avec BIND
handleclick() { console.log("this.state"); }
<button onClick={this.handleclick.bind(this)}>Cliquez moi</button>
avec zero fonction (plug de babel)
handleclick() { console.log("this.state"); }
<button onClick={ () => this.handleclick()}>Cliquez moi</button>
avec fonction fléchée (plug de babel)
handleclick = () => { console.log(this.state);}
<button onClick={this.handleclick}>Cliquez moi</button>
SETSTATE
chandleclick = () => {
this.setState({compteur: this.state.compteur+1});
console.log(this.state);
}
dev/reactdiver.1640697508.txt.gz · Dernière modification : 2021/12/28 13:18 de sbestel
