Skip to content

Instantly share code, notes, and snippets.

@vinayakhumberi
Created March 11, 2020 10:36
Show Gist options
  • Save vinayakhumberi/4bb6b375df94ed4260875babf77b5ad4 to your computer and use it in GitHub Desktop.
Save vinayakhumberi/4bb6b375df94ed4260875babf77b5ad4 to your computer and use it in GitHub Desktop.
React Lazy Suspense
import React, { Suspense } from 'react';
const OtherComponent = React.lazy(() => import('./OtherComponent'));
function MyComponent() {
return (
<div>
<Suspense fallback={<div>Loading...</div>}>
<OtherComponent />
</Suspense>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment