fix: await params in dynamic route for Next.js 15 compatibility
In Next.js 15, dynamic route params are now Promises and must be awaited before accessing properties.
This commit is contained in:
parent
687f5aab4e
commit
8c924c0b27
|
|
@ -10,20 +10,21 @@ import { Suspense } from 'react';
|
||||||
import Loader from '@/components/Loader';
|
import Loader from '@/components/Loader';
|
||||||
|
|
||||||
interface IParams {
|
interface IParams {
|
||||||
params: {
|
params: Promise<{
|
||||||
video_id: number;
|
video_id: number;
|
||||||
category_id: string;
|
category_id: string;
|
||||||
content_url: string;
|
content_url: string;
|
||||||
banner_url: string;
|
banner_url: string;
|
||||||
};
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VideoItem = async ({ params }: IParams) => {
|
const VideoItem = async ({ params }: IParams) => {
|
||||||
|
const { video_id } = await params;
|
||||||
const queryClient = getQueryClient();
|
const queryClient = getQueryClient();
|
||||||
|
|
||||||
await queryClient.prefetchQuery({
|
await queryClient.prefetchQuery({
|
||||||
queryKey: ['video', `video:${params.video_id}`],
|
queryKey: ['video', `video:${video_id}`],
|
||||||
queryFn: () => Queries.getVideo(params.video_id),
|
queryFn: () => Queries.getVideo(video_id),
|
||||||
});
|
});
|
||||||
await queryClient.prefetchInfiniteQuery({
|
await queryClient.prefetchInfiniteQuery({
|
||||||
queryKey: ['video', 'all'],
|
queryKey: ['video', 'all'],
|
||||||
|
|
@ -57,7 +58,7 @@ const VideoItem = async ({ params }: IParams) => {
|
||||||
<Loader height={700} />
|
<Loader height={700} />
|
||||||
</div>
|
</div>
|
||||||
}>
|
}>
|
||||||
<InfoBlock video_id={params.video_id} />
|
<InfoBlock video_id={video_id} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
<div className="video-item-inner w-full flex flex-col gap-4">
|
<div className="video-item-inner w-full flex flex-col gap-4">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue