mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
When there's a runtime error showing in root layout (server components), it should be able to catch by `global-error`. For server components, we caught it and gonna render the error fallback components (either not-found or error page), and the response status is `200`, and since we'll display error dev overlay in developmenet mode so we only render `global-error` for production. So that you can catch more errors with `global-error` and maybe do potential error tracking on client side. Follow up of #52573 Closes NEXT-1442 minor refactor: move `appUsingSizeAdjust` into `Metadata` component so that we can just tune the flag as prop
21 lines
345 B
JavaScript
21 lines
345 B
JavaScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
|
|
export default function Page() {
|
|
const [clicked, setClicked] = useState(false)
|
|
if (clicked) {
|
|
throw new Error('Client error')
|
|
}
|
|
return (
|
|
<button
|
|
id="error-trigger-button"
|
|
onClick={() => {
|
|
setClicked(true)
|
|
}}
|
|
>
|
|
Trigger Error!
|
|
</button>
|
|
)
|
|
}
|