{"size": 862, "ext": "js", "max_stars_repo_path": "src/app/components/Root.js", "max_stars_repo_name": "belfz/react-lion", "max_stars_repo_stars_event_min_datetime": "2015-11-05T21:02:55.000Z", "max_stars_repo_stars_event_max_datetime": "2015-11-05T21:02:55.000Z", "max_issues_repo_path": "src/app/components/Root.js", "max_issues_repo_name": "belfz/react-lion", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app/components/Root.js", "max_forks_repo_name": "belfz/react-lion", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.5238095238, "max_line_length": 54, "alphanum_fraction": 0.6438515081}
import React from 'react';
import Counter from './Counter';
import CounterStore from '../stores/CounterStore';
import Example from './Example';
import config from '../../../config/app';

function getState () {
  return {
    count: CounterStore.getCount()
  };
}

class Root extends React.Component {
  constructor (props) {
    super(props);
    this.state = getState();
    this._onChange = this._onChange.bind(this);
  }
  
  componentDidMount () {
    CounterStore.addChangeListener(this._onChange);
  }
  
  componentWillUnmount () {
    CounterStore.removeChangeListener(this._onChange);
  }
  
  render () {
    return (<div className="main">
      <h1>{config.title}</h1>
      <Counter count={this.state.count} />
      <Example count={this.state.count} />
    </div>);
  }
  
  _onChange () {
    this.setState(getState());
  }
}

export default Root;
