Created
June 9, 2019 13:26
-
-
Save NiallJoeMaher/f0cdeb91ec2d22a3b4faaf3731248284 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Before | |
import OtherComponent from './OtherComponent'; | |
function MyComponent() { | |
return ( | |
<div> | |
<OtherComponent /> | |
</div> | |
); | |
} | |
// After | |
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