Skip to content

Commit

Permalink
small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
amannn committed Nov 19, 2024
1 parent eaf67fa commit 7e09d85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/example-app-router/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {notFound} from 'next/navigation';
import {hasLocale} from 'next-intl';
import {getLocale, getTranslations} from 'next-intl/server';
import {getTranslations} from 'next-intl/server';
import {ReactNode} from 'react';
import BaseLayout from '@/components/BaseLayout';
import {routing} from '@/i18n/routing';

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

export function generateStaticParams() {
Expand All @@ -21,9 +24,9 @@ export async function generateMetadata() {
};
}

export default async function LocaleLayout({children}: Props) {
export default async function LocaleLayout({children, params}: Props) {
// This is only necessary as long as there's no `dynamicParams = false`
const locale = await getLocale();
const {locale} = await params;
if (!hasLocale(routing.locales, locale)) {
notFound();
}
Expand Down
1 change: 1 addition & 0 deletions examples/example-app-router/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ type Props = {
// Since we have a `not-found.tsx` page on the root, a layout file
// is required, even if it's just passing children through.
export default function RootLayout({children}: Props) {
// TODO: Can we get rid of this?
return children;
}

0 comments on commit 7e09d85

Please sign in to comment.