Skip to content

Instantly share code, notes, and snippets.

@bradfrost
Last active March 21, 2019 13:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfrost/dce1fe99ee66adbe858a8b1643f223c4 to your computer and use it in GitHub Desktop.
Save bradfrost/dce1fe99ee66adbe858a8b1643f223c4 to your computer and use it in GitHub Desktop.
const DynamicComponent = React.lazy(() =>
import(`path/to/${reactComponentName}`)
);
return (
//This works, but now how to I crawl in and grab its properties and PropTypes?
<Suspense fallback={<div>Loading...</div>}>
<DynamicComponent title="Lazy loaded component" />
</Suspense>
)
@kamranayub
Copy link

Would this work?

https://codesandbox.io/s/o5wxz1wv29?fontsize=14

import() returns a Promise that will resolve the module; you could dive in there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment