-
-
Save GQAdonis/fbc5cc2233bc2631ec78 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
/** @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