Hi there,
I searched other threads before creating. Found similar questions. But the approved solutions are not working for me. So I'm creating mine.
This code works while I do pnpm run dev, I can see the post loaded.
// app/blog/[slug]/page.tsx
import { notFound } from "next/navigation";
import BlogPost from "@/components/BlogPost";
import db from "@/db/index";
import { Post } from "@/db/schema";
import { eq } from "drizzle-orm";
type Props = {
params: Promise<{ slug: string }>;
};
export default async function Page(props: Props) {
const { slug } = await props.params;
const post = await db.select().from(Post).where(eq(Post.slug, slug)).limit(1);
if (!post.length) {
notFound();
}
return <BlogPost post={post[0]} />;
}
But If I do pnpm run build then I get this error:
.next/types/app/blog/page/[page]/page.ts:34:29
Type error: Type '{ params: { page: string; }; }' does not satisfy the constraint 'PageProps'.
Types of property 'params' are incompatible.
Type '{ page: string; }' is missing the following properties from type 'Promise<any>': then, catch, finally, [Symbol.toStringTag]
32 |
33 | // Check the prop type of the entry function
> 34 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
| ^
35 |
36 | // Check the arguments and return type of the generateMetadata function
37 | if ('generateMetadata' in entry) {
ELIFECYCLE Command failed with exit code 1.```
I also tried with things like `params: Promise<{slug: string}> | {slug:string}`
And matched how it was done here:
<https://nextjs.org/docs/canary/app/building-your-application/upgrading/version-15#asynchronous-page>
<https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes>
<https://discord.com/channels/752553802359505017/1299939488654561361>
I'm being unable to solve the problem.
What I'm doing wrong ?