Skip to content

Instantly share code, notes, and snippets.

@LeoLeBras
Last active January 21, 2016 16:42
Show Gist options
  • Save LeoLeBras/b3fed20de647d907fcd7 to your computer and use it in GitHub Desktop.
Save LeoLeBras/b3fed20de647d907fcd7 to your computer and use it in GitHub Desktop.
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