@@ -217,6 +217,12 @@ function Root({ children }: React.PropsWithChildren<{}>) {
217217 return children
218218}
219219
220+ const reactRootOptions = {
221+ onRecoverableError,
222+ onCaughtError,
223+ onUncaughtError,
224+ } satisfies ReactDOMClient . RootOptions
225+
220226export function hydrate ( ) {
221227 const reactEl = (
222228 < StrictModeIfEnabled >
@@ -231,19 +237,6 @@ export function hydrate() {
231237 const rootLayoutMissingTags = window . __next_root_layout_missing_tags
232238 const hasMissingTags = ! ! rootLayoutMissingTags ?. length
233239
234- const errorCallbacks =
235- typeof ( React as any ) . captureOwnerStack === 'function' &&
236- process . env . NODE_ENV !== 'production'
237- ? {
238- onCaughtError,
239- onUncaughtError,
240- }
241- : undefined
242-
243- const options = {
244- onRecoverableError,
245- ...errorCallbacks ,
246- } satisfies ReactDOMClient . RootOptions
247240 const isError =
248241 document . documentElement . id === '__next_error__' || hasMissingTags
249242
@@ -252,14 +245,18 @@ export function hydrate() {
252245 const createDevOverlayElement =
253246 require ( './components/react-dev-overlay/client-entry' ) . createDevOverlayElement
254247 const errorTree = createDevOverlayElement ( reactEl )
255- ReactDOMClient . createRoot ( appElement as any , options ) . render ( errorTree )
248+ ReactDOMClient . createRoot ( appElement as any , reactRootOptions ) . render (
249+ errorTree
250+ )
256251 } else {
257- ReactDOMClient . createRoot ( appElement as any , options ) . render ( reactEl )
252+ ReactDOMClient . createRoot ( appElement as any , reactRootOptions ) . render (
253+ reactEl
254+ )
258255 }
259256 } else {
260257 React . startTransition ( ( ) =>
261258 ( ReactDOMClient as any ) . hydrateRoot ( appElement , reactEl , {
262- ...options ,
259+ ...reactRootOptions ,
263260 formState : initialFormStateData ,
264261 } )
265262 )
0 commit comments