Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/react-devtools-shared/src/backend/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* @flow
*/

import type {ConsolePatchSettings} from './types';
import type {
ConsolePatchSettings,
OnErrorOrWarning,
GetComponentStack,
} from './types';

import {
formatConsoleArguments,
Expand Down Expand Up @@ -75,11 +79,6 @@ function restorePotentiallyModifiedArgs(args: Array<any>): Array<any> {
}
}

type OnErrorOrWarning = (type: 'error' | 'warn', args: Array<any>) => void;
type GetComponentStack = (
topFrame: Error,
) => null | {enableOwnerStacks: boolean, componentStack: string};

const injectedRenderers: Array<{
onErrorOrWarning: ?OnErrorOrWarning,
getComponentStack: ?GetComponentStack,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/backend/fiber/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5789,8 +5789,10 @@ export function attach(
inspectElement,
logElementToConsole,
patchConsoleForStrictMode,
getComponentStack,
getElementAttributeByPath,
getElementSourceFunctionById,
onErrorOrWarning,
overrideError,
overrideSuspense,
overrideValueAtPath,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-devtools-shared/src/backend/flight/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export function attach(
getBestMatchForTrackedPath() {
return null;
},
getComponentStack,
getDisplayNameForElementID() {
return null;
},
Expand Down Expand Up @@ -207,6 +208,7 @@ export function attach(
patchConsoleForStrictMode() {},
getElementAttributeByPath() {},
getElementSourceFunctionById() {},
onErrorOrWarning,
overrideError() {},
overrideSuspense() {},
overrideValueAtPath() {},
Expand Down
10 changes: 10 additions & 0 deletions packages/react-devtools-shared/src/backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ export type InstanceAndStyle = {

type Type = 'props' | 'hooks' | 'state' | 'context';

export type OnErrorOrWarning = (
type: 'error' | 'warn',
args: Array<any>,
) => void;
export type GetComponentStack = (
topFrame: Error,
) => null | {enableOwnerStacks: boolean, componentStack: string};

export type RendererInterface = {
cleanup: () => void,
clearErrorsAndWarnings: () => void,
Expand All @@ -364,6 +372,7 @@ export type RendererInterface = {
findHostInstancesForElementID: FindHostInstancesForElementID,
flushInitialOperations: () => void,
getBestMatchForTrackedPath: () => PathMatch | null,
getComponentStack?: GetComponentStack,
getNearestMountedDOMNode: (component: Element) => Element | null,
getElementIDForHostInstance: GetElementIDForHostInstance,
getDisplayNameForElementID: GetDisplayNameForElementID,
Expand All @@ -386,6 +395,7 @@ export type RendererInterface = {
forceFullData: boolean,
) => InspectedElementPayload,
logElementToConsole: (id: number) => void,
onErrorOrWarning?: OnErrorOrWarning,
overrideError: (id: number, forceError: boolean) => void,
overrideSuspense: (id: number, forceFallback: boolean) => void,
overrideValueAtPath: (
Expand Down