Created
April 16, 2016 17:05
-
-
Save nguyenvanduocit/3fb852d4df6b5b50d285c407359be70c 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
var RandomMessage = React.createClass({ | |
getInitialState: function() { | |
return { message: 'Hello, Universe' }; | |
}, | |
onClick: function() { | |
var messages = ['Hello, World', 'Hello, Planet', 'Hello, Universe']; | |
var randomMessage = messages[Math.floor((Math.random() * 3))]; | |
this.setState({ message: randomMessage }); | |
}, | |
render: function() { | |
return ( | |
<div> | |
<MessageView message={ this.state.message }/> | |
<p><input type="button" onClick={ this.onClick } value="Change Message"/></p> | |
</div> | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment