Created
October 29, 2018 01:55
-
-
Save isacjunior/af484732a8f6e5f4ccd1b18a3ffee3ae 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
import React, { Suspense, lazy } from 'react' | |
function LazyImport(Component) { | |
const ComponentLoadable = lazy(Component) | |
return props => ( | |
<Suspense fallback={<div>Loading...</div>}> | |
<ComponentLoadable {...props} /> | |
</Suspense> | |
); | |
} | |
export default LazyImport |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment