Last active
August 29, 2015 14:17
-
-
Save tomatau/ba1e034e6b3b11aed41c to your computer and use it in GitHub Desktop.
Click Handler
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
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