Files
Zack TannerandGitHub 3da48113f9 propagate notFound errors past a segment's error boundary (#60567)
### What?
Throwing a `notFound()` error inside of a segment that has an error
boundary will cause it to be handled by the segment's error boundary
rather than a parent not-found boundary.

### Why?
We assume anything that hits an `ErrorBoundary` is an actual error, but
this should not be the case when the caught error is one that is handled
by Next.js.

### How?
This checks if the caught error is one that is expected to be handled
someplace else.

Closes NEXT-2080
[slack
x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1705003189392509?thread_ts=1704868742.169129&cid=C03S8ED1DKM)
2024-01-12 16:58:45 +01:00

19 lines
351 B
JavaScript

'use client'
import { notFound } from 'next/navigation'
import React from 'react'
export default function Page() {
const [shouldError, setShouldError] = React.useState(false)
if (shouldError) {
notFound()
}
return (
<button
onClick={() => {
setShouldError(true)
}}
>
Trigger Not Found
</button>
)
}