Cannot destructure property 'children' of 'param' as it is undefined.
Unanswered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
I have error in this file.
Uncaught (in promise) TypeError: Cannot destructure property 'children' of 'param' as it is undefined.
at RootLayout (webpack-internal:///(app-client)/./src/app/[locale]/layout.tsx:40:13)
It happens when I go on a non-existent route
/src/app/[locale]/(main)/(sections)/sections/[...section]/page.tsx
And errors happens in this root file:
/src/app/[locale]/layout.tsx
Uncaught (in promise) TypeError: Cannot destructure property 'children' of 'param' as it is undefined.
at RootLayout (webpack-internal:///(app-client)/./src/app/[locale]/layout.tsx:40:13)
It happens when I go on a non-existent route
/src/app/[locale]/(main)/(sections)/sections/[...section]/page.tsx
if (categories) {
currentCategory = findCategory(categories, arrayOfSections)
if (!currentCategory) notFound()
}And errors happens in this root file:
/src/app/[locale]/layout.tsx
'use client'
import { RootStoreProvider } from '@store/rootStoreProvider'
import { SSRProvider } from '@use-platform/react'
import 'focus-visible'
import { NextIntlClientProvider } from 'next-intl'
import { notFound } from 'next/navigation'
import { ReactNode } from 'react'
import '../globals.scss'
export function generateStaticParams() {
return [{ locale: 'en' }, { locale: 'ru' }]
}
type RootLayoutProps = {
children: ReactNode
params: { locale: string }
}
async function getMessages(locale: string) {
try {
return (await import(`../../../messages/${locale}.json`)).default
} catch (error) {
notFound()
}
}
const RootLayout = async (param: RootLayoutProps) => {
const { children, params: { locale } } = param
const messages = await getMessages(locale)
console.log(children)
return (
<SSRProvider>
<html lang={locale} data-js-focus-visible="" className="js-focus-visible">
<head>
<link rel="icon" href="/assets/images/favicon.svg" sizes="any" />
</head>
<body>
<NextIntlClientProvider locale={locale} messages={messages}>
<RootStoreProvider>{children}</RootStoreProvider>
</NextIntlClientProvider>
</body>
</html>
</SSRProvider>
)
}
export default RootLayout