Next.js Discord

Discord Forum

not found doesnt import root layout

Unanswered
Japanese anchovy posted this in #help-forum
Open in Discord
Avatar
Japanese anchovyOP
Hello, i am using the app router and i have my folder structure as
app
- page.tsx
- not-found.tsx
- error.tsx
- layout.tsx

And i noticed when i use my custom 404 page it doesnt automaticaly import root layout yet the error page does. Is this a bug?

404
import ErrorInformation from "@components/404/error-information"
import RootLayout from "./layout"

export default function Page() {
    return (
        <RootLayout>
            <ErrorInformation />
        </RootLayout>
        )

}


error page
'use client' // Error components must be Client Components

import React, { useEffect } from 'react'
import Button from "@components/ui/button"
import {useRouter} from 'next/navigation'
export default function Error({
                                  error,
                                  reset,
                              }: {
    error: Error & { digest?: string }
    reset: () => void
}) {
    const router = useRouter()
    useEffect(() => {
        // Log the error to an error reporting service
        console.error(error)
    }, [error])

    return (
        <div>
           <ErrorPage/>
        </div>
    )
}

3 Replies

Avatar
Vespid wasp
Same problem here. Seems to be intended but not sure why
Avatar
joulev & fuma pray for Schneider
a recent regression that was caused by https://github.com/vercel/next.js/pull/52589 most likely