Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

test only using "use client" #36

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
26 changes: 4 additions & 22 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Suspense, use } from "react";
import { Suspense } from "react";
import { CreatePostForm } from "~/client/CreatePostForm";
import { HydrateClient } from "~/client/HydrateClient";
import { PostList } from "~/components/PostList";
import { PostListItem } from "~/components/PostListItem";
import { rsc } from "../server-rsc/trpc";

function PostListSkeleton() {
return (
Expand All @@ -15,22 +13,6 @@ function PostListSkeleton() {
);
}

function PostListRSC() {
use(
Promise.all([
rsc.post.list.fetchInfinite({}),
// Display loading for at least 300ms
new Promise((resolve) => setTimeout(resolve, 3_00)),
]),
);

return (
<HydrateClient state={use(rsc.dehydrate())}>
<PostList />
</HydrateClient>
);
}

export default async function Page() {
return (
<div className='space-y-6 p-4'>
Expand Down Expand Up @@ -61,9 +43,9 @@ export default async function Page() {
<h2>All posts</h2>

<div className='overflow-hidden bg-white shadow rounded-md'>
<Suspense fallback={<PostListSkeleton />}>
<PostListRSC />
</Suspense>
{/* <Suspense fallback={<PostListSkeleton />}> */}
<PostList />
{/* </Suspense> */}
</div>
</section>
</div>
Expand Down
1 change: 1 addition & 0 deletions components/PostList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function PostList() {
},
refetchOnMount: false,
staleTime: Infinity,
suspense: true,
},
);

Expand Down