content: /**
   * External dependencies
   */
  import React from 'react'
  import PropTypes from 'prop-types'
  import { omit } from 'lodash'
  
  export default class AsyncLoader extends React.Component {
  	static propTypes = {
  		require: PropTypes.func.isRequired
  	}
  
  	constructor() {
  		super(...arguments)
  
  		this.state = {
  			require: null
  		}
  	}
  
  	componentWillMount() {
  		this.require()
  	}
  
  	componentWillReceiveProps(nextProps) {
  		if (this.props.require !== nextProps.require) {
  			this.setState({
  				require: null
  			})
  		}
  	}
  
  	componentDidUpdate(prevProps) {
  		if (this.props.require !== prevProps.require) {
  			this.require()
  		}
  	}
  
  	require() {
  		const requireFunction = this.props.require
  
  		requireFunction((component) => {
  			if (this.props.require === requireFunction) {
  				this.setState({component})
  			}
  		})
  	}
  
  	render() {
  		const props = omit(this.props, ['require'])
  
  		if (this.state.component) {
  			return <this.state.component {...props}/>
  		}
  
  		return null
  	}
  }