Last active
January 21, 2016 16:42
-
-
Save LeoLeBras/b3fed20de647d907fcd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter extends React.Component { | |
constructor() { | |
super(); | |
this.state = { count: 0 }; // Initialisation des données de départ | |
} | |
increment() { | |
this.setState({ count: this.state.count + 1 }); // Mise à jour des données | |
} | |
render() { | |
return ( | |
<div> | |
<h1>{ this.state.count }</h1> | |
<button onClick={ () => this.increment()) }>Increment</button> | |
</div> | |
); | |
} | |
} | |
React.render( <Counter />, document.body ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment