content: /*globals document*/
  
  import React from 'react';
  import Nav from './Nav';
  import Home from './Home';
  import About from './About';
  import ApplicationStore from '../stores/ApplicationStore';
  import provideContext from 'fluxible/addons/provideContext';
  import connectToStores from 'fluxible/addons/connectToStores';
  import { handleHistory } from 'fluxible-router';
  
  // @TODO Upgrade to ES6 class when RouterMixin is replaced
  var Application = React.createClass({
      propTypes: {
          context: React.PropTypes.object.isRequired
      },
      render: function () {
          // Returns the expected componentContext.demonstrate value
          console.log('Application', 'this.props.context.demonstrate', this.props.context.demonstrate);
          var Handler = this.props.currentRoute.get('handler');
  
          return (
              <div>
                  <Nav selected={this.props.currentPageName} links={this.props.pages} />
                  <Handler />
              </div>
          );
      },
  
      componentDidUpdate: function(prevProps, prevState) {
          const newProps = this.props;
          if (newProps.pageTitle === prevProps.pageTitle) {
              return;
          }
          document.title = newProps.pageTitle;
      }
  });
  
  export default handleHistory(provideContext(connectToStores(
      Application,
      [ApplicationStore],
      function (stores, props) {
          var appStore = stores.ApplicationStore;
          return {
              currentPageName: appStore.getCurrentPageName(),
              pageTitle: appStore.getPageTitle(),
              pages: appStore.getPages()
          };
      }
  ), { // child context types
      demonstrate: React.PropTypes.func.isRequired
  }));
  