Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Created February 24, 2019 14:04
Show Gist options
  • Save anushshukla/feed06c71a36a4fe5d9f12f49ab0a344 to your computer and use it in GitHub Desktop.
Save anushshukla/feed06c71a36a4fe5d9f12f49ab0a344 to your computer and use it in GitHub Desktop.
import React from 'react';
export default dynamicImport =>
class MockAsyncComponent extends React.Component {
state = { Component: null };
componentDidMount = () => dynamicImport.then(({ default: Component }) => this.setState({ Component })).error(error => null);
render = () => {
const { Component } = this.state;
console.error(Component);
return <Component {...this.props} />;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment