mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What Fix the status code in static generation metadata for `/_not-found` route, aligning it as 404 for both dev and build ### Why `/_not-found` route should still return 404 code as it's reserved as default not found route Closes NEXT-3001
29 lines
658 B
JavaScript
29 lines
658 B
JavaScript
'use client'
|
|
|
|
import { useState, Suspense } from 'react'
|
|
import { notFound } from 'next/navigation'
|
|
import NotFoundTrigger from './not-found-trigger'
|
|
|
|
export default function Root({ children }) {
|
|
const [clicked, setClicked] = useState(false)
|
|
if (clicked) {
|
|
notFound()
|
|
}
|
|
|
|
return (
|
|
<html className="root-layout-html">
|
|
<body>
|
|
<Suspense fallback={<div>Loading...</div>}>
|
|
<NotFoundTrigger />
|
|
</Suspense>
|
|
<button id="trigger-not-found" onClick={() => setClicked(true)}>
|
|
Click to not found
|
|
</button>
|
|
{children}
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|
|
export const dynamic = 'force-dynamic'
|