Skip to content

Commit efd9c73

Browse files
committed
[dev-overlay] Remove unused code when handling hydration mismatches
1 parent 55203ff commit efd9c73

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/next/src/client/components/errors/attach-hydration-error-state.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
2-
getDefaultHydrationErrorMessage,
32
isHydrationError,
43
testReactHydrationWarning,
54
} from '../is-hydration-error'
65
import {
76
hydrationErrorState,
87
getReactHydrationDiffSegments,
8+
type HydrationErrorState,
99
} from './hydration-error-info'
1010

1111
export function attachHydrationErrorState(error: Error) {
@@ -27,15 +27,14 @@ export function attachHydrationErrorState(error: Error) {
2727
if (reactHydrationDiffSegments) {
2828
const diff = reactHydrationDiffSegments[1]
2929
parsedHydrationErrorState = {
30-
...(error as any).details,
30+
...((error as any).details as HydrationErrorState),
3131
...hydrationErrorState,
3232
// If diff is present in error, we don't need to pick up the console logged warning.
3333
// - if hydration error has diff, and is not hydration diff log, then it's a normal hydration error.
3434
// - if hydration error no diff, then leverage the one from the hydration diff log.
3535

36-
warning: (diff && !isHydrationWarning
37-
? null
38-
: hydrationErrorState.warning) || [getDefaultHydrationErrorMessage()],
36+
warning:
37+
diff && !isHydrationWarning ? undefined : hydrationErrorState.warning,
3938
// When it's hydration diff log, do not show notes section.
4039
// This condition is only for the 1st squashed error.
4140
notes: isHydrationWarning ? '' : reactHydrationDiffSegments[0],

packages/next/src/client/components/is-hydration-error.ts

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ export const REACT_HYDRATION_ERROR_LINK =
1515
export const NEXTJS_HYDRATION_ERROR_LINK =
1616
'https://nextjs.org/docs/messages/react-hydration-error'
1717

18-
export const getDefaultHydrationErrorMessage = () => {
19-
return reactUnifiedMismatchWarning
20-
}
21-
2218
export function isHydrationError(error: unknown): boolean {
2319
return isError(error) && hydrationErrorRegex.test(error.message)
2420
}

0 commit comments

Comments
 (0)