Skip to content

Commit

Permalink
no devTools yet
Browse files Browse the repository at this point in the history
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
  • Loading branch information
devjiwonchoi and huozhi committed Jan 23, 2025
1 parent 557e370 commit 288c3d0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import type { GlobalErrorComponent } from '../../../error-boundary'
import { PureComponent } from 'react'
import { RuntimeErrorHandler } from '../../../errors/runtime-error-handler'

type DevToolsErrorBoundaryProps = {
type DevOverlayErrorBoundaryProps = {
children: React.ReactNode
devTools: React.ReactNode
devOverlay: React.ReactNode
globalError: [GlobalErrorComponent, React.ReactNode]
onError: (value: boolean) => void
}

type DevToolsErrorBoundaryState = {
type DevOverlayErrorBoundaryState = {
isReactError: boolean
reactError: unknown
}
Expand Down Expand Up @@ -38,9 +38,9 @@ function ErroredHtml({
)
}

export class DevToolsErrorBoundary extends PureComponent<
DevToolsErrorBoundaryProps,
DevToolsErrorBoundaryState
export class DevOverlayErrorBoundary extends PureComponent<
DevOverlayErrorBoundaryProps,
DevOverlayErrorBoundaryState
> {
state = { isReactError: false, reactError: null }

Expand All @@ -62,7 +62,7 @@ export class DevToolsErrorBoundary extends PureComponent<
}

render() {
const { children, globalError, devTools } = this.props
const { children, globalError, devOverlay } = this.props
const { isReactError, reactError } = this.state

const fallback = (
Expand All @@ -72,7 +72,7 @@ export class DevToolsErrorBoundary extends PureComponent<
return (
<>
{isReactError ? fallback : children}
{devTools}
{devOverlay}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OverlayState } from '../../shared'
import type { GlobalErrorComponent } from '../../../error-boundary'

import { useState } from 'react'
import { DevToolsErrorBoundary } from './error-boundary'
import { DevOverlayErrorBoundary } from './error-boundary'
import { ShadowPortal } from '../internal/components/shadow-portal'
import { Base } from '../internal/styles/base'
import { ComponentStyles } from '../internal/styles/component-styles'
Expand All @@ -24,7 +24,7 @@ export default function ReactDevOverlay({
const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(false)
const { readyErrors } = useErrorHook({ errors: state.errors, isAppDir: true })

const devTools = (
const devOverlay = (
<ShadowPortal>
<CssReset />
<Base />
Expand All @@ -47,12 +47,12 @@ export default function ReactDevOverlay({
)

return (
<DevToolsErrorBoundary
devTools={devTools}
<DevOverlayErrorBoundary
devOverlay={devOverlay}
globalError={globalError}
onError={setIsErrorOverlayOpen}
>
{children}
</DevToolsErrorBoundary>
</DevOverlayErrorBoundary>
)
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import * as React from 'react'

type DevToolsErrorBoundaryProps = {
type DevOverlayErrorBoundaryProps = {
children?: React.ReactNode
onError: (error: Error, componentStack: string | null) => void
isMounted?: boolean
}
type DevToolsErrorBoundaryState = { error: Error | null }
type DevOverlayErrorBoundaryState = { error: Error | null }

export class DevToolsErrorBoundary extends React.PureComponent<
DevToolsErrorBoundaryProps,
DevToolsErrorBoundaryState
export class DevOverlayErrorBoundary extends React.PureComponent<
DevOverlayErrorBoundaryProps,
DevOverlayErrorBoundaryState
> {
state = { error: null }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Base } from '../internal/styles/base'
import { ComponentStyles } from '../internal/styles/component-styles'
import { CssReset } from '../internal/styles/css-reset'

import { DevToolsErrorBoundary } from './error-boundary'
import { DevOverlayErrorBoundary } from './error-boundary'
import { usePagesReactDevOverlay } from '../../pages/hooks'
import { Colors } from '../internal/styles/colors'
import { ErrorOverlay } from '../internal/components/errors/error-overlay/error-overlay'
Expand Down Expand Up @@ -37,9 +37,9 @@ export default function ReactDevOverlay({ children }: ReactDevOverlayProps) {

return (
<>
<DevToolsErrorBoundary isMounted={isMounted} onError={onComponentError}>
<DevOverlayErrorBoundary isMounted={isMounted} onError={onComponentError}>
{children ?? null}
</DevToolsErrorBoundary>
</DevOverlayErrorBoundary>

{isMounted && (
<ShadowPortal>
Expand Down
6 changes: 3 additions & 3 deletions test/development/app-dir/owner-stack/owner-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('app-dir - owner-stack', () => {
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevToolsErrorBoundary> error boundary."
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
Expand All @@ -107,7 +107,7 @@ describe('app-dir - owner-stack', () => {
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevToolsErrorBoundary> error boundary."
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`)
}
} else {
Expand Down Expand Up @@ -238,7 +238,7 @@ describe('app-dir - owner-stack', () => {
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevToolsErrorBoundary> error boundary."
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
Expand Down

0 comments on commit 288c3d0

Please sign in to comment.