Skip to content

Instantly share code, notes, and snippets.

@GQAdonis
Forked from petehunt/gist:5687276
Last active September 5, 2015 16:18
Show Gist options
  • Save GQAdonis/fbc5cc2233bc2631ec78 to your computer and use it in GitHub Desktop.
Save GQAdonis/fbc5cc2233bc2631ec78 to your computer and use it in GitHub Desktop.
/** @jsx React.DOM */
var MyRootComponent = React.createClass({
getInitialState: function() {
return {perMinute: '-', perDay: '-'};
},
componentDidMount: function() {
var socket = io.connect(this.props.url);
socket.on('business.clickout', this.setState.bind(this));
},
render: function() {
return <MyComponent perMinute={this.state.perMinute} perDay={this.state.perDay} />;
}
});
var MyComponent = React.createClass({
render: function() {
var perMinute = this.props.perMinute;
var perDay = this.props.perDay;
return (
<div>
<h3>Clickouts</h3>
<p>last Minute: {perMinute}</p>
<p>today: {perDay}</p>
</div>
);
}
});
React.renderComponent(
<MyRootComponent url="http://localhost:3000" />,
document.getElementById('domid')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment