const React = require('react'); const createClass = require('create-react-class'); const cx = require('classnames'); const request = require('superagent'); const Stats = createClass({ displayName : 'Stats', getDefaultProps(){ return {}; }, getInitialState(){ return { stats : { totalBrews : 0 }, fetching : false }; }, componentDidMount(){ this.fetchStats(); }, fetchStats(){ this.setState({ fetching: true }); request.get('/admin/stats') .then((res)=>this.setState({ stats: res.body })) .finally(()=>this.setState({ fetching: false })); }, render(){ return

Stats

Total Brew Count
{this.state.stats.totalBrews}
{this.state.fetching &&
}
; } }); module.exports = Stats;