Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { unstable_noStore } from "next/cache";
import { redirect } from "next/navigation";
import { Link } from "react-transition-progress/next";

export default async function SlowPage() {
export default async function SlowPage({ params: promisedParams }: { params: { slug: string } }) {
const params = await promisedParams
const { slug } = params
unstable_noStore();
// Introduces artificial slowdown
await new Promise((resolve) => setTimeout(resolve, 1000));
await new Promise((resolve) => setTimeout(resolve, 3000));

if (slug === 'foo') {
redirect('/bar')
}

return (
<div className="m-10">
<h1 className="mb-2 text-4xl font-semibold">Slow page, artificially slowed by 1 second</h1>
<h2>{slug}</h2>
<Link href="/">Go to home page</Link>
</div>
);
}
}
5 changes: 3 additions & 2 deletions examples/nextjs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export default function Home() {
<>
<div className="m-10">
<h1 className="mb-4 text-4xl font-semibold"><a href="https://github.com/timneutkens/react-transition-progress">react-transition-progress</a></h1>
<Link href="/slow">Go to artificially slow page</Link>
<Link href="/foo">Foo</Link><br />
<Link href="/bar">Bar</Link>
</div>
<div className="m-10">
<h2 className="mb-2 text-2xl font-semibold">Client Component that calls slow action</h2>
Expand All @@ -30,4 +31,4 @@ export default function Home() {
</div>
</>
);
}
}