Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/data-grid-live/components/data-grid-live-demo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useLiveQuery } from "@tanstack/react-db";
import type { ColumnDef, SortingState } from "@tanstack/react-table";
import { CheckCircle2, Palette, Trash2, X } from "lucide-react";
import * as React from "react";
import { use } from "react";
import { toast } from "sonner";
import { skatersCollection } from "@/app/data-grid-live/lib/collections";
import {
Expand Down Expand Up @@ -82,6 +83,8 @@ const trickSelectOptions = trickOptions.map((trick) => ({
}));

export function DataGridLiveDemo() {
use(skatersCollection.preload());

const windowSize = useWindowSize();
const [sorting, setSorting] = React.useState<SortingState>([
{ id: "createdAt", desc: false },
Expand Down
18 changes: 8 additions & 10 deletions src/app/data-grid-live/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import dynamic from "next/dynamic";
import { use } from "react";
import { skatersCollection } from "@/app/data-grid-live/lib/collections";
import { Skeleton } from "@/components/ui/skeleton";

// Dynamic import to prevent SSR issues with useLiveQuery
// Dynamic import with ssr: false is required because:
// 1. useLiveQuery uses useSyncExternalStore which needs getServerSnapshot for SSR
// 2. Collection preload triggers fetch() which rejects during prerendering
const DataGridLiveDemo = dynamic(
() =>
import("./components/data-grid-live-demo").then(
Expand All @@ -16,19 +16,17 @@ const DataGridLiveDemo = dynamic(
loading: () => (
<div className="container flex h-[calc(100dvh-5.5rem)] flex-col gap-4 py-4">
<div className="flex items-center gap-2 self-end">
<Skeleton className="h-7 w-18" />
<Skeleton className="h-7 w-18" />
<Skeleton className="h-7 w-18" />
<Skeleton className="h-7 w-20" />
<Skeleton className="h-7 w-20" />
<Skeleton className="h-7 w-20" />
<Skeleton className="hidden h-7 w-20 lg:block" />
Comment thread
sadmann7 marked this conversation as resolved.
</div>
<Skeleton className="h-full w-full" />
<Skeleton className="size-full" />
</div>
),
},
);

export default function DataGridLivePage() {
// Preload the collection before rendering
use(skatersCollection.preload());

return <DataGridLiveDemo />;
}