Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
0a87d752
Unverified
Commit
0a87d752
authored
Jun 03, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Jun 03, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] Inject `getSquashedHydrationErrorDetails` implementation (#80046)
Same as with `get*Stack` implementation
parent
69765f4d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
8 deletions
+51
-8
app-dev-overlay.tsx
...ient/components/react-dev-overlay/app/app-dev-overlay.tsx
+10
-1
hydration-error-state.ts
...mponents/react-dev-overlay/pages/hydration-error-state.ts
+1
-1
pages-dev-overlay.tsx
.../components/react-dev-overlay/pages/pages-dev-overlay.tsx
+6
-1
error-overlay.tsx
...rlay/ui/components/errors/error-overlay/error-overlay.tsx
+4
-0
errors.tsx
...ient/components/react-dev-overlay/ui/container/errors.tsx
+12
-4
dev-overlay.stories.tsx
...t/components/react-dev-overlay/ui/dev-overlay.stories.tsx
+12
-1
dev-overlay.tsx
...rc/client/components/react-dev-overlay/ui/dev-overlay.tsx
+6
-0
No files found.
packages/next/src/client/components/react-dev-overlay/app/app-dev-overlay.tsx
View file @
0a87d752
...
@@ -72,6 +72,11 @@ function ReplaySsrOnlyErrors({
...
@@ -72,6 +72,11 @@ function ReplaySsrOnlyErrors({
return
null
return
null
}
}
function
getSquashedHydrationErrorDetails
()
{
// We don't squash hydration errors in the App Router.
return
null
}
export
function
AppDevOverlay
({
export
function
AppDevOverlay
({
state
,
state
,
dispatch
,
dispatch
,
...
@@ -99,7 +104,11 @@ export function AppDevOverlay({
...
@@ -99,7 +104,11 @@ export function AppDevOverlay({
<>
<>
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
<
FontStyles
/>
<
FontStyles
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
/>
</>
</>
</>
</>
)
)
...
...
packages/next/src/client/components/react-dev-overlay/pages/hydration-error-state.ts
View file @
0a87d752
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
isErrorMessageWithComponentStackDiff
as
isReact19HydrationWarning
,
isErrorMessageWithComponentStackDiff
as
isReact19HydrationWarning
,
}
from
'../../react-19-hydration-error'
}
from
'../../react-19-hydration-error'
type
HydrationErrorState
=
{
export
type
HydrationErrorState
=
{
// Hydration warning template format: <message> <serverContent> <clientContent>
// Hydration warning template format: <message> <serverContent> <clientContent>
warning
?:
string
warning
?:
string
reactOutputComponentDiff
?:
string
reactOutputComponentDiff
?:
string
...
...
packages/next/src/client/components/react-dev-overlay/pages/pages-dev-overlay.tsx
View file @
0a87d752
...
@@ -2,6 +2,7 @@ import { PagesDevOverlayErrorBoundary } from './pages-dev-overlay-error-boundary
...
@@ -2,6 +2,7 @@ import { PagesDevOverlayErrorBoundary } from './pages-dev-overlay-error-boundary
import
{
usePagesDevOverlay
}
from
'./hooks'
import
{
usePagesDevOverlay
}
from
'./hooks'
import
{
FontStyles
}
from
'../font/font-styles'
import
{
FontStyles
}
from
'../font/font-styles'
import
{
DevOverlay
}
from
'../ui/dev-overlay'
import
{
DevOverlay
}
from
'../ui/dev-overlay'
import
{
getSquashedHydrationErrorDetails
}
from
'./hydration-error-state'
export
type
ErrorType
=
'runtime'
|
'build'
export
type
ErrorType
=
'runtime'
|
'build'
...
@@ -22,7 +23,11 @@ export function PagesDevOverlay({ children }: PagesDevOverlayProps) {
...
@@ -22,7 +23,11 @@ export function PagesDevOverlay({ children }: PagesDevOverlayProps) {
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
<
FontStyles
/>
<
FontStyles
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
/>
</>
</>
)
)
}
}
packages/next/src/client/components/react-dev-overlay/ui/components/errors/error-overlay/error-overlay.tsx
View file @
0a87d752
...
@@ -9,6 +9,7 @@ import { BuildError } from '../../../container/build-error'
...
@@ -9,6 +9,7 @@ import { BuildError } from '../../../container/build-error'
import
{
Errors
}
from
'../../../container/errors'
import
{
Errors
}
from
'../../../container/errors'
import
{
useDelayedRender
}
from
'../../../hooks/use-delayed-render'
import
{
useDelayedRender
}
from
'../../../hooks/use-delayed-render'
import
type
{
ReadyRuntimeError
}
from
'../../../../utils/get-error-by-type'
import
type
{
ReadyRuntimeError
}
from
'../../../../utils/get-error-by-type'
import
type
{
HydrationErrorState
}
from
'../../../../pages/hydration-error-state'
const
transitionDurationMs
=
200
const
transitionDurationMs
=
200
...
@@ -23,11 +24,13 @@ export interface ErrorBaseProps {
...
@@ -23,11 +24,13 @@ export interface ErrorBaseProps {
export
function
ErrorOverlay
({
export
function
ErrorOverlay
({
state
,
state
,
dispatch
,
dispatch
,
getSquashedHydrationErrorDetails
,
runtimeErrors
,
runtimeErrors
,
errorCount
,
errorCount
,
}:
{
}:
{
state
:
OverlayState
state
:
OverlayState
dispatch
:
OverlayDispatch
dispatch
:
OverlayDispatch
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
runtimeErrors
:
ReadyRuntimeError
[]
runtimeErrors
:
ReadyRuntimeError
[]
errorCount
:
number
errorCount
:
number
})
{
})
{
...
@@ -74,6 +77,7 @@ export function ErrorOverlay({
...
@@ -74,6 +77,7 @@ export function ErrorOverlay({
<
Errors
<
Errors
{
...
commonProps
}
{
...
commonProps
}
debugInfo=
{
state
.
debugInfo
}
debugInfo=
{
state
.
debugInfo
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
runtimeErrors=
{
runtimeErrors
}
runtimeErrors=
{
runtimeErrors
}
onClose=
{
()
=>
{
onClose=
{
()
=>
{
dispatch
({
type
:
ACTION_ERROR_OVERLAY_CLOSE
})
dispatch
({
type
:
ACTION_ERROR_OVERLAY_CLOSE
})
...
...
packages/next/src/client/components/react-dev-overlay/ui/container/errors.tsx
View file @
0a87d752
...
@@ -17,9 +17,10 @@ import {
...
@@ -17,9 +17,10 @@ import {
}
from
'../../../react-19-hydration-error'
}
from
'../../../react-19-hydration-error'
import
type
{
ReadyRuntimeError
}
from
'../../utils/get-error-by-type'
import
type
{
ReadyRuntimeError
}
from
'../../utils/get-error-by-type'
import
type
{
ErrorBaseProps
}
from
'../components/errors/error-overlay/error-overlay'
import
type
{
ErrorBaseProps
}
from
'../components/errors/error-overlay/error-overlay'
import
{
getSquashedHydrationErrorDetails
}
from
'../../pages/hydration-error-state'
import
type
{
HydrationErrorState
}
from
'../../pages/hydration-error-state'
export
interface
ErrorsProps
extends
ErrorBaseProps
{
export
interface
ErrorsProps
extends
ErrorBaseProps
{
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
runtimeErrors
:
ReadyRuntimeError
[]
runtimeErrors
:
ReadyRuntimeError
[]
debugInfo
:
DebugInfo
debugInfo
:
DebugInfo
onClose
:
()
=>
void
onClose
:
()
=>
void
...
@@ -72,7 +73,10 @@ const noErrorDetails = {
...
@@ -72,7 +73,10 @@ const noErrorDetails = {
notes
:
null
,
notes
:
null
,
reactOutputComponentDiff
:
null
,
reactOutputComponentDiff
:
null
,
}
}
function
useErrorDetails
(
error
:
Error
|
undefined
):
{
function
useErrorDetails
(
error
:
Error
|
undefined
,
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
):
{
hydrationWarning
:
string
|
null
hydrationWarning
:
string
|
null
notes
:
string
|
null
notes
:
string
|
null
reactOutputComponentDiff
:
string
|
null
reactOutputComponentDiff
:
string
|
null
...
@@ -106,10 +110,11 @@ function useErrorDetails(error: Error | undefined): {
...
@@ -106,10 +110,11 @@ function useErrorDetails(error: Error | undefined): {
notes
,
notes
,
reactOutputComponentDiff
:
diff
,
reactOutputComponentDiff
:
diff
,
}
}
},
[
error
])
},
[
error
,
getSquashedHydrationErrorDetails
])
}
}
export
function
Errors
({
export
function
Errors
({
getSquashedHydrationErrorDetails
,
runtimeErrors
,
runtimeErrors
,
debugInfo
,
debugInfo
,
onClose
,
onClose
,
...
@@ -127,7 +132,10 @@ export function Errors({
...
@@ -127,7 +132,10 @@ export function Errors({
()
=>
runtimeErrors
[
activeIdx
]
??
null
,
()
=>
runtimeErrors
[
activeIdx
]
??
null
,
[
activeIdx
,
runtimeErrors
]
[
activeIdx
,
runtimeErrors
]
)
)
const
errorDetails
=
useErrorDetails
(
activeError
?.
error
)
const
errorDetails
=
useErrorDetails
(
activeError
?.
error
,
getSquashedHydrationErrorDetails
)
if
(
isLoading
)
{
if
(
isLoading
)
{
// TODO: better loading state
// TODO: better loading state
...
...
packages/next/src/client/components/react-dev-overlay/ui/dev-overlay.stories.tsx
View file @
0a87d752
...
@@ -102,6 +102,10 @@ function useOverlayReducer() {
...
@@ -102,6 +102,10 @@ function useOverlayReducer() {
},
initialState
)
},
initialState
)
}
}
function
getNoSquashedHydrationErrorDetails
()
{
return
null
}
export
const
Default
:
Story
=
{
export
const
Default
:
Story
=
{
render
:
function
DevOverlayStory
()
{
render
:
function
DevOverlayStory
()
{
const
[
state
,
dispatch
]
=
useOverlayReducer
()
const
[
state
,
dispatch
]
=
useOverlayReducer
()
...
@@ -115,7 +119,14 @@ export const Default: Story = {
...
@@ -115,7 +119,14 @@ export const Default: Story = {
objectFit
:
'contain'
,
objectFit
:
'contain'
,
}
}
}
}
/>
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
/>
<
DevOverlay
state=
{
state
}
dispatch=
{
dispatch
}
getSquashedHydrationErrorDetails=
{
// Testing like App Router where we no longer quash hydration errors
getNoSquashedHydrationErrorDetails
}
/>
</>
</>
)
)
},
},
...
...
packages/next/src/client/components/react-dev-overlay/ui/dev-overlay.tsx
View file @
0a87d752
...
@@ -10,13 +10,16 @@ import { DevToolsIndicator } from './components/errors/dev-tools-indicator/dev-t
...
@@ -10,13 +10,16 @@ import { DevToolsIndicator } from './components/errors/dev-tools-indicator/dev-t
import
{
RenderError
}
from
'./container/runtime-error/render-error'
import
{
RenderError
}
from
'./container/runtime-error/render-error'
import
{
DarkTheme
}
from
'./styles/dark-theme'
import
{
DarkTheme
}
from
'./styles/dark-theme'
import
{
useDevToolsScale
}
from
'./components/errors/dev-tools-indicator/dev-tools-info/preferences'
import
{
useDevToolsScale
}
from
'./components/errors/dev-tools-indicator/dev-tools-info/preferences'
import
type
{
HydrationErrorState
}
from
'../pages/hydration-error-state'
export
function
DevOverlay
({
export
function
DevOverlay
({
state
,
state
,
dispatch
,
dispatch
,
getSquashedHydrationErrorDetails
,
}:
{
}:
{
state
:
OverlayState
state
:
OverlayState
dispatch
:
OverlayDispatch
dispatch
:
OverlayDispatch
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
})
{
})
{
const
[
scale
,
setScale
]
=
useDevToolsScale
()
const
[
scale
,
setScale
]
=
useDevToolsScale
()
return
(
return
(
...
@@ -46,6 +49,9 @@ export function DevOverlay({
...
@@ -46,6 +49,9 @@ export function DevOverlay({
<
ErrorOverlay
<
ErrorOverlay
state=
{
state
}
state=
{
state
}
dispatch=
{
dispatch
}
dispatch=
{
dispatch
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
runtimeErrors=
{
runtimeErrors
}
runtimeErrors=
{
runtimeErrors
}
errorCount=
{
totalErrorCount
}
errorCount=
{
totalErrorCount
}
/>
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment