|
1 |
| -import { ReactNode, useState } from "react" |
| 1 | +import { lazy, ReactNode, Suspense, useState } from "react" |
2 | 2 | import type { GetStaticProps, InferGetStaticPropsType } from "next"
|
3 |
| -import dynamic from "next/dynamic" |
4 | 3 | import { useRouter } from "next/router"
|
5 | 4 | import { useTranslation } from "next-i18next"
|
6 | 5 | import { serverSideTranslations } from "next-i18next/serverSideTranslations"
|
@@ -238,10 +237,13 @@ const CodeblockSkeleton = () => (
|
238 | 237 | </Stack>
|
239 | 238 | )
|
240 | 239 |
|
241 |
| -const Codeblock = dynamic(() => import("@/components/Codeblock"), { |
242 |
| - ssr: false, |
243 |
| - loading: () => <CodeblockSkeleton />, |
244 |
| -}) |
| 240 | +const Codeblock = lazy(() => |
| 241 | + Promise.all([ |
| 242 | + import("@/components/Codeblock"), |
| 243 | + // Add a delay to prevent the skeleton from flashing |
| 244 | + new Promise((resolve) => setTimeout(resolve, 1000)), |
| 245 | + ]).then(([module]) => module) |
| 246 | +) |
245 | 247 |
|
246 | 248 | const HomePage = ({
|
247 | 249 | communityEvents,
|
@@ -558,13 +560,15 @@ const HomePage = ({
|
558 | 560 | setIsOpen={setModalOpen}
|
559 | 561 | title={codeExamples[activeCode].title}
|
560 | 562 | >
|
561 |
| - <Codeblock |
562 |
| - codeLanguage={codeExamples[activeCode].codeLanguage} |
563 |
| - allowCollapse={false} |
564 |
| - fromHomepage |
565 |
| - > |
566 |
| - {codeExamples[activeCode].code} |
567 |
| - </Codeblock> |
| 563 | + <Suspense fallback={<CodeblockSkeleton />}> |
| 564 | + <Codeblock |
| 565 | + codeLanguage={codeExamples[activeCode].codeLanguage} |
| 566 | + allowCollapse={false} |
| 567 | + fromHomepage |
| 568 | + > |
| 569 | + {codeExamples[activeCode].code} |
| 570 | + </Codeblock> |
| 571 | + </Suspense> |
568 | 572 | </CodeModal>
|
569 | 573 | )}
|
570 | 574 | </Row>
|
|
0 commit comments