Skip to content

Instantly share code, notes, and snippets.

@tomatau
Last active August 29, 2015 14:17
Show Gist options
  • Save tomatau/ba1e034e6b3b11aed41c to your computer and use it in GitHub Desktop.
Save tomatau/ba1e034e6b3b11aed41c to your computer and use it in GitHub Desktop.
Click Handler
let MyComponent = React.createClass({
getInitialState(){
return { who: 'world!', unchanged: 'I dont change' };
},
render(){
return (
<span className='hello' onClick={this.handleClick}>
Hello, {this.state.who}
</span>
)
},
handleClick(event){
let { who } = this.state;
this.setState({
who: (who == 'you!') ? 'world!' : 'you!'
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment