diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 78e65c1c0a..c56576ff18 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 e7fb09d0d8..528c8abe91 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'; @@ -106,29 +107,11 @@ 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, - 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 0b44ef7f81..379821e187 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -4,8 +4,13 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format + * @noformat * @flow strict + * @nolint + * @generated SignedSource<> + * @generated SignedSource<> + * + * This file was sync'd from the facebook/react repository. */ import type {ElementRef, ElementType, Element, AbstractComponent} from 'react'; @@ -174,6 +179,25 @@ export type TouchedViewDataAtPoint = $ReadOnly<{ ...InspectorData, }>; +export type RenderRootOptions = { + onUncaughtError?: ( + error: mixed, + errorInfo: {+componentStack?: ?string}, + ) => void, + onCaughtError?: ( + error: mixed, + errorInfo: { + +componentStack?: ?string, + // $FlowFixMe[unclear-type] unknown props and state. + +errorBoundary?: ?React$Component, + }, + ) => void, + onRecoverableError?: ( + error: mixed, + errorInfo: {+componentStack?: ?string}, + ) => void, +}; + /** * Flat ReactNative renderer bundles are too big for Flow to parse efficiently. * Provide minimal Flow typing for the high-level RN API and call it a day. @@ -202,6 +226,7 @@ export type ReactNativeType = { element: Element, containerTag: number, callback: ?() => void, + options: ?RenderRootOptions, ): ?ElementRef, unmountComponentAtNode(containerTag: number): void, unmountComponentAtNodeAndRemoveContainer(containerTag: number): void, @@ -237,6 +262,7 @@ export type ReactFabricType = { containerTag: number, callback: ?() => void, concurrentRoot: ?boolean, + options: ?RenderRootOptions, ): ?ElementRef, unmountComponentAtNode(containerTag: number): void, getNodeFromInternalInstanceHandle(