Skip to content

Commit 897f317

Browse files
committed
fix: add suspense boundaries for uncached data (next 16)
1 parent 5418ee2 commit 897f317

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/app/admin/layout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { motion, AnimatePresence } from "framer-motion";
44
import { useTheme } from "next-themes";
55
import { Switch } from "@/components/ui/switch";
66
import { Sun, Moon, Cpu } from "lucide-react";
7-
import { useEffect, useState } from "react";
7+
import { useEffect, useState, Suspense } from "react";
88
import TRPCProvider from "@/lib/trpc/provider";
99
import { SilkProvider } from "./SilkContext";
1010
import AdminBackground from "@/components/background/admin-background";
@@ -92,7 +92,17 @@ function AdminLayoutInner({ children }: { children: React.ReactNode }) {
9292
<SilkProvider setSilkColorAction={setSilkColor}>
9393
<AnimatedAdminBackground color={silkColor} />
9494
<TopBar />
95-
<div className="min-h-screen text-slate-50">{children}</div>
95+
<div className="min-h-screen text-slate-50">
96+
<Suspense
97+
fallback={
98+
<div className="flex min-h-screen items-center justify-center">
99+
<div className="h-8 w-8 animate-spin rounded-full border-4 border-slate-200 border-t-transparent" />
100+
</div>
101+
}
102+
>
103+
{children}
104+
</Suspense>
105+
</div>
96106
</SilkProvider>
97107
</TRPCProvider>
98108
);

src/app/poll/layout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1-
import PublicTRPCProvider from "@/lib/trpc/public-provider";
1+
import { Suspense } from "react";
22

33
export default function PollLayout({
44
children,
55
}: {
66
children: React.ReactNode;
77
}) {
8-
return <PublicTRPCProvider>{children}</PublicTRPCProvider>;
8+
return (
9+
<Suspense
10+
fallback={
11+
<div className="flex min-h-screen items-center justify-center">
12+
<div className="h-8 w-8 animate-spin rounded-full border-4 border-slate-200 border-t-transparent" />
13+
</div>
14+
}
15+
>
16+
{children}
17+
</Suspense>
18+
);
919
}

0 commit comments

Comments
 (0)