Skip to content

Instantly share code, notes, and snippets.

@anushshukla
Created February 24, 2019 14:03
Show Gist options
  • Save anushshukla/378f69ae4ba49b15937d52d56da65cea to your computer and use it in GitHub Desktop.
Save anushshukla/378f69ae4ba49b15937d52d56da65cea to your computer and use it in GitHub Desktop.
import React, { Suspense, lazy } from 'react';
const DefaultSpinner = () => null;
export default (dynamicImport, Spinner) => {
const Component = lazy(dynamicImport);
return props => (
<Suspense fallback={Spinner ? <Spinner /> : <DefaultSpinner />}>
<Component {...props} />
</Suspense>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment