Skip to content

Commit

Permalink
[DevOverlay] Decouple Error Overlay with DevTools Indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
devjiwonchoi committed Jan 16, 2025
1 parent ed3187a commit ddf157e
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { OverlayState } from '../../../../../shared'

import { BuildError } from '../../../container/BuildError'
import { Errors } from '../../../container/Errors'

export function ErrorOverlay({ state }: { state: OverlayState }) {
const isTurbopack = !!process.env.TURBOPACK

// This occurs only at the App Router, so dynamic require the component.
if (!!state.rootLayoutMissingTags?.length) {
const { RootLayoutMissingTagsError } =
require('../../../container/RootLayoutMissingTagsError') as typeof import('../../../container/RootLayoutMissingTagsError')

return (
<RootLayoutMissingTagsError
missingTags={state.rootLayoutMissingTags}
versionInfo={state.versionInfo}
isTurbopack={isTurbopack}
/>
)
}

if (state.buildError !== null) {
return (
<BuildError
message={state.buildError}
versionInfo={state.versionInfo}
isTurbopack={isTurbopack}
/>
)
}

// No Runtime Errors.
if (!state.errors.length) {
return null
}

return (
<Errors
isTurbopack={isTurbopack}
isAppDir={true}
initialDisplayState={isReactError ? 'fullscreen' : 'minimized'}
errors={state.errors}
versionInfo={state.versionInfo}
hasStaticIndicator={hasStaticIndicator}
debugInfo={debugInfo}
/>
)
}

0 comments on commit ddf157e

Please sign in to comment.