Skip to content

Commit

Permalink
use async params
Browse files Browse the repository at this point in the history
  • Loading branch information
yo-iwamoto committed Nov 10, 2024
1 parent 7e2cc1b commit 8c09805
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export function generateStaticParams() {
}

type Props = PropsWithChildren<{
params: {
params: Promise<{
locale: string;
};
}>;
}>;

export async function generateMetadata({ params: { locale } }: Props) {
export async function generateMetadata({ params }: Props) {
const { locale } = await params;
const t = await getTranslations("metadata");

return {
Expand All @@ -28,7 +29,8 @@ export async function generateMetadata({ params: { locale } }: Props) {
} satisfies Metadata;
}

export default function Layout({ children, params: { locale } }: Props) {
export default async function Layout({ children, params }: Props) {
const { locale } = await params;
initializeLocale(locale);

return (
Expand Down
7 changes: 4 additions & 3 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { initializeLocale } from "@/i18n/initialize-locale";

type Props = {
params: {
params: Promise<{
locale: string;
};
}>;
};

export default function Page({ params: { locale } }: Props) {
export default async function Page({ params }: Props) {
const { locale } = await params;
initializeLocale(locale);

return (
Expand Down

0 comments on commit 8c09805

Please sign in to comment.