Using Shortcodes with React lazy #1492
-
I'd like to split up my components using React lazy. Can I do this using MDX shortcodes? I'm currently getting this error:
...
const CICD = React.lazy( () => import( 'components/Icons/CICD' ) )
...
const components = {
DocsGrid,
CICD: <>
{
typeof window ==! "undefined" && <React.Suspense
fallback={<div height={`200pt`}></div>}
><CICD /></React.Suspense>
}
</>
}
...
<MDXProvider components={components}>
{children} |
Beta Was this translation helpful? Give feedback.
Answered by
ChristianMurphy
Mar 24, 2021
Replies: 1 comment 9 replies
-
The error you're getting is because you are passing a rendered element instead of a component. const components = {
DocsGrid,
CICD: () => (<>
{
typeof window ==! "undefined" && <React.Suspense
fallback={<div height={`200pt`}></div>}
><CICD /></React.Suspense>
}
</>)
} should work. |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
ChristianMurphy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The error you're getting is because you are passing a rendered element instead of a component.
should work.