fix: move ssr:false dynamic imports into client component
Turbopack disallows ssr:false in Server Components. Extracted the three
recharts dynamic imports into charts-client.tsx ("use client"), which
page.tsx now imports from directly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
import { Skeleton } from "~/components/ui/skeleton";
|
||||||
|
|
||||||
|
const chartSkeleton = () => <Skeleton className="h-64 w-full" />;
|
||||||
|
|
||||||
|
export const RevenueChart = dynamic(
|
||||||
|
() => import("./revenue-chart").then((m) => m.RevenueChart),
|
||||||
|
{ ssr: false, loading: chartSkeleton },
|
||||||
|
);
|
||||||
|
|
||||||
|
export const InvoiceStatusChart = dynamic(
|
||||||
|
() => import("./invoice-status-chart").then((m) => m.InvoiceStatusChart),
|
||||||
|
{ ssr: false, loading: chartSkeleton },
|
||||||
|
);
|
||||||
|
|
||||||
|
export const MonthlyMetricsChart = dynamic(
|
||||||
|
() => import("./monthly-metrics-chart").then((m) => m.MonthlyMetricsChart),
|
||||||
|
{ ssr: false, loading: chartSkeleton },
|
||||||
|
);
|
||||||
@@ -20,20 +20,7 @@ import { auth } from "~/lib/auth";
|
|||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
import { HydrateClient, api } from "~/trpc/server";
|
import { HydrateClient, api } from "~/trpc/server";
|
||||||
import type { StoredInvoiceStatus } from "~/types/invoice";
|
import type { StoredInvoiceStatus } from "~/types/invoice";
|
||||||
import dynamic from "next/dynamic";
|
import { RevenueChart, InvoiceStatusChart, MonthlyMetricsChart } from "~/app/dashboard/_components/charts-client";
|
||||||
|
|
||||||
const RevenueChart = dynamic(
|
|
||||||
() => import("~/app/dashboard/_components/revenue-chart").then((m) => m.RevenueChart),
|
|
||||||
{ ssr: false, loading: () => <Skeleton className="h-64 w-full" /> },
|
|
||||||
);
|
|
||||||
const InvoiceStatusChart = dynamic(
|
|
||||||
() => import("~/app/dashboard/_components/invoice-status-chart").then((m) => m.InvoiceStatusChart),
|
|
||||||
{ ssr: false, loading: () => <Skeleton className="h-64 w-full" /> },
|
|
||||||
);
|
|
||||||
const MonthlyMetricsChart = dynamic(
|
|
||||||
() => import("~/app/dashboard/_components/monthly-metrics-chart").then((m) => m.MonthlyMetricsChart),
|
|
||||||
{ ssr: false, loading: () => <Skeleton className="h-64 w-full" /> },
|
|
||||||
);
|
|
||||||
import { AnimatedStatsCard } from "~/app/dashboard/_components/animated-stats-card";
|
import { AnimatedStatsCard } from "~/app/dashboard/_components/animated-stats-card";
|
||||||
import type { DashboardStats, RecentInvoice } from "./types";
|
import type { DashboardStats, RecentInvoice } from "./types";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user