import type {Fiber} from '../ReactFiber';
import type {CapturedValue} from '../ReactCapturedValue';
import {ClassComponent} from '../ReactWorkTags';
import {ReactFiberErrorDialog as RNImpl} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
if (typeof RNImpl.showErrorDialog !== 'function') {
throw new Error(
'Expected ReactFiberErrorDialog.showErrorDialog to be a function.',
);
}
export function showErrorDialog(
boundary: Fiber,
errorInfo: CapturedValue<mixed>,
): boolean {
const capturedError = {
componentStack: errorInfo.stack !== null ? errorInfo.stack : '',
error: errorInfo.value,
errorBoundary:
boundary !== null && boundary.tag === ClassComponent
? boundary.stateNode
: null,
};
return RNImpl.showErrorDialog(capturedError);
}