Created
March 11, 2020 10:36
-
-
Save vinayakhumberi/4bb6b375df94ed4260875babf77b5ad4 to your computer and use it in GitHub Desktop.
React Lazy Suspense
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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