Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nguyenvanduocit
Created April 16, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nguyenvanduocit/3fb852d4df6b5b50d285c407359be70c to your computer and use it in GitHub Desktop.
Save nguyenvanduocit/3fb852d4df6b5b50d285c407359be70c to your computer and use it in GitHub Desktop.
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