[flow] Eliminate usage of global React types in ReactNativeTypes.js (#32330)
Sam Zhou committed
Feb 20, 2025 at 12:42 UTC
70f1d766e8ae7ca3701193abb8c8a9f2fdbdaa9d
2 files changed
+11
-3
packages/react-native-renderer/src/ReactNativeTypes.js
+10
-3
@@ -9,7 +9,13 @@
9
* @flow strict
10
*/
11
12
-import type {ElementRef, ElementType, MixedElement} from 'react';
12
+import type {
13
+ Component as ReactComponent,
14
+ ElementRef,
15
+ ElementType,
16
+ MixedElement,
17
+ RefSetter,
18
+} from 'react';
19
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
20
import {type PublicRootInstance} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
21
@@ -135,7 +141,7 @@ declare const ensureNativeMethodsAreSynced: NativeMethods;
141
142
export type HostInstance = NativeMethods;
143
export type HostComponent<Config: {...}> = component(
138
- ref: React$RefSetter<HostInstance>,
144
+ ref: RefSetter<HostInstance>,
145
...Config
146
);
147
@@ -188,7 +194,8 @@ export type RenderRootOptions = {
194
errorInfo: {
195
+componentStack?: ?string,
196
// $FlowFixMe[unclear-type] unknown props and state.
191
- +errorBoundary?: ?React$Component<any, any>,
197
+ // $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
198
+ +errorBoundary?: ?ReactComponent<any, any>,
199
},
200
) => void,
201
onRecoverableError?: (
packages/react/index.js
+1
@@ -17,6 +17,7 @@ export type Key = React$Key;
17
export type Node = React$Node;
18
export type Context<T> = React$Context<T>;
19
export type Portal = React$Portal;
20
+export type RefSetter<-I> = React$RefSetter<I>;
21
export type ElementProps<C> = React$ElementProps<C>;
22
export type ElementConfig<C> = React$ElementConfig<C>;
23
export type ElementRef<C> = React$ElementRef<C>;