diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 78e65c1c0a26f..c56576ff18e2d 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -10,6 +10,7 @@ import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes'; import type {ElementRef, Element, ElementType} from 'react'; import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; +import type {RenderRootOptions} from './ReactNativeTypes'; import './ReactFabricInjection'; @@ -101,30 +102,12 @@ function nativeOnCaughtError( defaultOnCaughtError(error, errorInfo); } -type NativeRenderOptions = { - onUncaughtError?: ( - error: mixed, - errorInfo: {+componentStack?: ?string}, - ) => void, - onCaughtError?: ( - error: mixed, - errorInfo: { - +componentStack?: ?string, - +errorBoundary?: ?React$Component, - }, - ) => void, - onRecoverableError?: ( - error: mixed, - errorInfo: {+componentStack?: ?string}, - ) => void, -}; - function render( element: Element, containerTag: number, callback: ?() => void, concurrentRoot: ?boolean, - options?: NativeRenderOptions, + options: ?RenderRootOptions, ): ?ElementRef { if (disableLegacyMode && !concurrentRoot) { throw new Error('render: Unsupported Legacy Mode API.'); diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index e7fb09d0d8ddc..16dfef8a2f059 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -10,6 +10,7 @@ import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes'; import type {ElementRef, Element, ElementType} from 'react'; import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes'; +import type {RenderRootOptions} from './ReactNativeTypes'; import './ReactNativeInjection'; @@ -128,7 +129,7 @@ function render( element: Element, containerTag: number, callback: ?() => void, - options?: NativeRenderOptions, + options: ?RenderRootOptions, ): ?ElementRef { if (disableLegacyMode) { throw new Error('render: Unsupported Legacy Mode API.'); diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index 0b44ef7f81e39..94237f386623b 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -215,6 +215,24 @@ export opaque type InternalInstanceHandle = mixed; type PublicInstance = mixed; type PublicTextInstance = mixed; +export type RenderRootOptions = { + onUncaughtError?: ( + error: mixed, + errorInfo: {+componentStack?: ?string}, + ) => void, + onCaughtError?: ( + error: mixed, + errorInfo: { + +componentStack?: ?string, + +errorBoundary?: ?React$Component, + }, + ) => void, + onRecoverableError?: ( + error: mixed, + errorInfo: {+componentStack?: ?string}, + ) => void, +}; + export type ReactFabricType = { findHostInstance_DEPRECATED( componentOrHandle: ?(ElementRef | number), @@ -237,6 +255,7 @@ export type ReactFabricType = { containerTag: number, callback: ?() => void, concurrentRoot: ?boolean, + options: ?RenderRootOptions, ): ?ElementRef, unmountComponentAtNode(containerTag: number): void, getNodeFromInternalInstanceHandle(