Created
February 24, 2019 14:03
-
-
Save anushshukla/378f69ae4ba49b15937d52d56da65cea to your computer and use it in GitHub Desktop.
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, 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