Skip to content

Commit

Permalink
early return
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Feb 21, 2025
1 parent ca5d3af commit 5d13b9c
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ import {
} from './hydration-error-info'

export function attachHydrationErrorState(error: Error) {
const reactHydrationDiffSegments = getReactHydrationDiffSegments(
error.message
)
let parsedHydrationErrorState: typeof hydrationErrorState = {}
const isHydrationWarning = testReactHydrationWarning(error.message)
const isHydrationRuntimeError = isHydrationError(error)

// If it's not hydration warnings or errors, skip
if (!(isHydrationRuntimeError || isHydrationWarning)) {
return
}

const reactHydrationDiffSegments = getReactHydrationDiffSegments(
error.message
)
// If the reactHydrationDiffSegments exists
// and the diff (reactHydrationDiffSegments[1]) exists
// e.g. the hydration diff log error.
Expand Down Expand Up @@ -73,7 +79,5 @@ export function attachHydrationErrorState(error: Error) {
}
}
// If it's a hydration error, store the hydration error state into the error object
if (isHydrationRuntimeError || isHydrationWarning) {
;(error as any).details = parsedHydrationErrorState
}
;(error as any).details = parsedHydrationErrorState
}

0 comments on commit 5d13b9c

Please sign in to comment.