-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DevOverlay] Decouple Error Overlay with DevTools Indicator
- Loading branch information
1 parent
ed3187a
commit ddf157e
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...eact-dev-overlay/_experimental/internal/components/Errors/error-overlay/error-overlay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
/> | ||
) | ||
} |