Код: Выделить всё
import brandingData from '@/data/brandingData';
export default function ClientWebsite({ params }: { params: { client: string } }) {
const defaultConfig = {
title: "Welcome to Wuilder",
bgColor: "bg-gray-500",
logo: "/logos/default.png",
description: "Powerful websites for every business."
};
const clientConfig = brandingData[params.client] || defaultConfig;
return (
[img]{clientConfig.logo} alt=[/img]
{clientConfig.title}
{clientConfig.description}
);
}
< /code>
Он работал нормально, а также выставлять и отображать все данные из brandingdata.ts: < /p>
type BrandingConfig = {
title: string;
logo: string;
description: string;
};
const brandingData: Record = {
client1: {
title: "Client 1 - Tech Solutions",
logo: "/space/satelite-launch.jpg",
description: "Innovative tech solutions for modern businesses.",
},
client2: {
title: "Client 2 - Fashion Hub",
logo: "/space/gabriele-garanzelli-PzO_CitnJdI-unsplash.jpg",
description: "Trendy fashion and lifestyle brand.",
},
client3: {
title: "Client 3 - Coffee Express",
logo: "/space/spacex-OHOU-5UVIYQ-unsplash.jpg",
description: "The best coffee experience, delivered to you.",
}
};
export default brandingData;
< /code>
Но я получаю эту раздражающую ошибку в своей консоли: < /p>
Error: Route "/[client]" used `params.client`. `params` should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
at client (app\[client]\page.tsx:11:45)
9 | };
10 |
> 11 | const clientConfig = brandingData[params.client] || defaultConfig;
| ^
12 |
13 | return (
14 |
GET /client3 200 in 203ms
Я ожидаю, что эта ошибка исчезнет, помогите мне!
Подробнее здесь: https://stackoverflow.com/questions/794 ... ut-i-neede
Мобильная версия