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
Hide 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({
return
null
}
function
getSquashedHydrationErrorDetails
()
{
// We don't squash hydration errors in the App Router.
return
null
}
export
function
AppDevOverlay
({
state
,
dispatch
,
...
...
@@ -99,7 +104,11 @@ export function AppDevOverlay({
<>
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
<
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 {
isErrorMessageWithComponentStackDiff
as
isReact19HydrationWarning
,
}
from
'../../react-19-hydration-error'
type
HydrationErrorState
=
{
export
type
HydrationErrorState
=
{
// Hydration warning template format: <message> <serverContent> <clientContent>
warning
?:
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
import
{
usePagesDevOverlay
}
from
'./hooks'
import
{
FontStyles
}
from
'../font/font-styles'
import
{
DevOverlay
}
from
'../ui/dev-overlay'
import
{
getSquashedHydrationErrorDetails
}
from
'./hydration-error-state'
export
type
ErrorType
=
'runtime'
|
'build'
...
...
@@ -22,7 +23,11 @@ export function PagesDevOverlay({ children }: PagesDevOverlayProps) {
{
/* Fonts can only be loaded outside the Shadow DOM. */
}
<
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'
import
{
Errors
}
from
'../../../container/errors'
import
{
useDelayedRender
}
from
'../../../hooks/use-delayed-render'
import
type
{
ReadyRuntimeError
}
from
'../../../../utils/get-error-by-type'
import
type
{
HydrationErrorState
}
from
'../../../../pages/hydration-error-state'
const
transitionDurationMs
=
200
...
...
@@ -23,11 +24,13 @@ export interface ErrorBaseProps {
export
function
ErrorOverlay
({
state
,
dispatch
,
getSquashedHydrationErrorDetails
,
runtimeErrors
,
errorCount
,
}:
{
state
:
OverlayState
dispatch
:
OverlayDispatch
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
runtimeErrors
:
ReadyRuntimeError
[]
errorCount
:
number
})
{
...
...
@@ -74,6 +77,7 @@ export function ErrorOverlay({
<
Errors
{
...
commonProps
}
debugInfo=
{
state
.
debugInfo
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
runtimeErrors=
{
runtimeErrors
}
onClose=
{
()
=>
{
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 {
}
from
'../../../react-19-hydration-error'
import
type
{
ReadyRuntimeError
}
from
'../../utils/get-error-by-type'
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
{
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
runtimeErrors
:
ReadyRuntimeError
[]
debugInfo
:
DebugInfo
onClose
:
()
=>
void
...
...
@@ -72,7 +73,10 @@ const noErrorDetails = {
notes
:
null
,
reactOutputComponentDiff
:
null
,
}
function
useErrorDetails
(
error
:
Error
|
undefined
):
{
function
useErrorDetails
(
error
:
Error
|
undefined
,
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
):
{
hydrationWarning
:
string
|
null
notes
:
string
|
null
reactOutputComponentDiff
:
string
|
null
...
...
@@ -106,10 +110,11 @@ function useErrorDetails(error: Error | undefined): {
notes
,
reactOutputComponentDiff
:
diff
,
}
},
[
error
])
},
[
error
,
getSquashedHydrationErrorDetails
])
}
export
function
Errors
({
getSquashedHydrationErrorDetails
,
runtimeErrors
,
debugInfo
,
onClose
,
...
...
@@ -127,7 +132,10 @@ export function Errors({
()
=>
runtimeErrors
[
activeIdx
]
??
null
,
[
activeIdx
,
runtimeErrors
]
)
const
errorDetails
=
useErrorDetails
(
activeError
?.
error
)
const
errorDetails
=
useErrorDetails
(
activeError
?.
error
,
getSquashedHydrationErrorDetails
)
if
(
isLoading
)
{
// 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() {
},
initialState
)
}
function
getNoSquashedHydrationErrorDetails
()
{
return
null
}
export
const
Default
:
Story
=
{
render
:
function
DevOverlayStory
()
{
const
[
state
,
dispatch
]
=
useOverlayReducer
()
...
...
@@ -115,7 +119,14 @@ export const Default: Story = {
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
import
{
RenderError
}
from
'./container/runtime-error/render-error'
import
{
DarkTheme
}
from
'./styles/dark-theme'
import
{
useDevToolsScale
}
from
'./components/errors/dev-tools-indicator/dev-tools-info/preferences'
import
type
{
HydrationErrorState
}
from
'../pages/hydration-error-state'
export
function
DevOverlay
({
state
,
dispatch
,
getSquashedHydrationErrorDetails
,
}:
{
state
:
OverlayState
dispatch
:
OverlayDispatch
getSquashedHydrationErrorDetails
:
(
error
:
Error
)
=>
HydrationErrorState
|
null
})
{
const
[
scale
,
setScale
]
=
useDevToolsScale
()
return
(
...
...
@@ -46,6 +49,9 @@ export function DevOverlay({
<
ErrorOverlay
state=
{
state
}
dispatch=
{
dispatch
}
getSquashedHydrationErrorDetails=
{
getSquashedHydrationErrorDetails
}
runtimeErrors=
{
runtimeErrors
}
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