import React, { Children, PropTypes } from 'react';

const ContextType = {
	// Enables critical path CSS rendering
	// https://github.com/kriasoft/isomorphic-style-loader
	insertCss: PropTypes.func.isRequired,
	// Integrate Redux
	// http://redux.js.org/docs/basics/UsageWithReact.html
	store: PropTypes.shape({
		subscribe: PropTypes.func.isRequired,
		dispatch: PropTypes.func.isRequired,
		getState: PropTypes.func.isRequired,
	}).isRequired,
};

/**
 * The top-level React component setting context (global) variables
 * that can be accessed from all the child components.
 *
 * https://facebook.github.io/react/docs/context.html
 *
 * Usage example:
 *
 *	 const context = {
 *		 history: createBrowserHistory(),
 *		 store: createStore(),
 *	 };
 *
 *	 ReactDOM.render(
 *		 <App context={context}>
 *			 <Layout>
 *				 <LandingPage />
 *			 </Layout>
 *		 </App>,
 *		 container,
 *	 );
 */
class App extends React.PureComponent {

	static propTypes = {
		context: PropTypes.shape(ContextType).isRequired,
		children: PropTypes.element.isRequired,
	};

	static childContextTypes = ContextType;

	
() {
		return this.props.context;
	}

	render() {
		// NOTE: If you need to add or modify header, footer etc. of the app,
		// please do that inside the Layout component.
		return Children.only(this.props.children);
	}

}

export default App;

getChildContext