Add ReactNativeTypes for root options (#28850)
Flow should have failed for this but didn't, we need these options sync'd over in the types too.
Ricky committed
Apr 16, 2024 at 21:18 UTC
657428a9e960cc9c208498be7d2e293007d85cbd
3 files changed
+23
-38
packages/react-native-renderer/src/ReactFabric.js
+2
-19
@@ -10,6 +10,7 @@
10
import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes';
11
import type {ElementRef, Element, ElementType} from 'react';
12
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
13
+import type {RenderRootOptions} from './ReactNativeTypes';
14
15
import './ReactFabricInjection';
16
@@ -101,30 +102,12 @@ function nativeOnCaughtError(
102
defaultOnCaughtError(error, errorInfo);
103
}
104
104
-type NativeRenderOptions = {
105
- onUncaughtError?: (
106
- error: mixed,
107
- errorInfo: {+componentStack?: ?string},
108
- ) => void,
109
- onCaughtError?: (
110
- error: mixed,
111
- errorInfo: {
112
- +componentStack?: ?string,
113
- +errorBoundary?: ?React$Component<any, any>,
114
- },
115
- ) => void,
116
- onRecoverableError?: (
117
- error: mixed,
118
- errorInfo: {+componentStack?: ?string},
119
- ) => void,
120
-};
121
-
105
function render(
106
element: Element<ElementType>,
107
containerTag: number,
108
callback: ?() => void,
109
concurrentRoot: ?boolean,
127
- options?: NativeRenderOptions,
110
+ options: ?RenderRootOptions,
111
): ?ElementRef<ElementType> {
112
if (disableLegacyMode && !concurrentRoot) {
113
throw new Error('render: Unsupported Legacy Mode API.');
packages/react-native-renderer/src/ReactNativeRenderer.js
+2
-19
@@ -10,6 +10,7 @@
10
import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes';
11
import type {ElementRef, Element, ElementType} from 'react';
12
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
13
+import type {RenderRootOptions} from './ReactNativeTypes';
14
15
import './ReactNativeInjection';
16
@@ -106,29 +107,11 @@ function nativeOnCaughtError(
107
defaultOnCaughtError(error, errorInfo);
108
}
109
109
-type NativeRenderOptions = {
110
- onUncaughtError?: (
111
- error: mixed,
112
- errorInfo: {+componentStack?: ?string},
113
- ) => void,
114
- onCaughtError?: (
115
- error: mixed,
116
- errorInfo: {
117
- +componentStack?: ?string,
118
- +errorBoundary?: ?React$Component<any, any>,
119
- },
120
- ) => void,
121
- onRecoverableError?: (
122
- error: mixed,
123
- errorInfo: {+componentStack?: ?string},
124
- ) => void,
125
-};
126
-
110
function render(
111
element: Element<ElementType>,
112
containerTag: number,
113
callback: ?() => void,
131
- options?: NativeRenderOptions,
114
+ options: ?RenderRootOptions,
115
): ?ElementRef<ElementType> {
116
if (disableLegacyMode) {
117
throw new Error('render: Unsupported Legacy Mode API.');
packages/react-native-renderer/src/ReactNativeTypes.js
+19
@@ -215,6 +215,24 @@ export opaque type InternalInstanceHandle = mixed;
215
type PublicInstance = mixed;
216
type PublicTextInstance = mixed;
217
218
+export type RenderRootOptions = {
219
+ onUncaughtError?: (
220
+ error: mixed,
221
+ errorInfo: {+componentStack?: ?string},
222
+ ) => void,
223
+ onCaughtError?: (
224
+ error: mixed,
225
+ errorInfo: {
226
+ +componentStack?: ?string,
227
+ +errorBoundary?: ?React$Component<any, any>,
228
+ },
229
+ ) => void,
230
+ onRecoverableError?: (
231
+ error: mixed,
232
+ errorInfo: {+componentStack?: ?string},
233
+ ) => void,
234
+};
235
+
236
export type ReactFabricType = {
237
findHostInstance_DEPRECATED<TElementType: ElementType>(
238
componentOrHandle: ?(ElementRef<TElementType> | number),
@@ -237,6 +255,7 @@ export type ReactFabricType = {
255
containerTag: number,
256
callback: ?() => void,
257
concurrentRoot: ?boolean,
258
+ options: ?RenderRootOptions,
259
): ?ElementRef<ElementType>,
260
unmountComponentAtNode(containerTag: number): void,
261
getNodeFromInternalInstanceHandle(