Skip to content

Commit

Permalink
feat: add suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
Max-Mogilski committed Nov 14, 2023
1 parent d2bc8bd commit 74ff376
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/app/[lang]/category/[slug]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Skeleton } from "@/components/ui/Skeleton/Skeleton"

export default function Loading() {
return (
<div className="w-full">
<Skeleton className="min-h-[150px] w-full" />
</div>
)
}
8 changes: 7 additions & 1 deletion src/app/[lang]/category/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Metadata } from "next/types"
import { unstable_setRequestLocale } from "next-intl/server"
import { Suspense } from "react"
import { CategoryArticles } from "@/components/CategoryArticles/CategoryArticles"
import { Locale } from "@/i18n/i18n"
import { setTranslations } from "@/i18n/setTranslations"
import { getMatadataObj } from "@/utils/getMetadataObj"
import Loading from "./loading"

type ArticlePageProps = { params: { slug: string; lang: Locale } }

Expand All @@ -15,5 +17,9 @@ export default async function Web({ params: { slug, lang } }: ArticlePageProps)
unstable_setRequestLocale(lang)
await setTranslations(lang)

return <CategoryArticles category={slug} />
return (
<Suspense fallback={<Loading />}>
<CategoryArticles category={slug} />
</Suspense>
)
}

0 comments on commit 74ff376

Please sign in to comment.