Skip to content

Commit 70f1d76

Browse files
authored
[flow] Eliminate usage of global React types in ReactNativeTypes.js (#32330)
1 parent 885532c commit 70f1d76

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/react-native-renderer/src/ReactNativeTypes.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
* @flow strict
1010
*/
1111

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';
1319
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
1420
import {type PublicRootInstance} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
1521

@@ -135,7 +141,7 @@ declare const ensureNativeMethodsAreSynced: NativeMethods;
135141

136142
export type HostInstance = NativeMethods;
137143
export type HostComponent<Config: {...}> = component(
138-
ref: React$RefSetter<HostInstance>,
144+
ref: RefSetter<HostInstance>,
139145
...Config
140146
);
141147

@@ -188,7 +194,8 @@ export type RenderRootOptions = {
188194
errorInfo: {
189195
+componentStack?: ?string,
190196
// $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>,
192199
},
193200
) => void,
194201
onRecoverableError?: (

packages/react/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Key = React$Key;
1717
export type Node = React$Node;
1818
export type Context<T> = React$Context<T>;
1919
export type Portal = React$Portal;
20+
export type RefSetter<-I> = React$RefSetter<I>;
2021
export type ElementProps<C> = React$ElementProps<C>;
2122
export type ElementConfig<C> = React$ElementConfig<C>;
2223
export type ElementRef<C> = React$ElementRef<C>;

0 commit comments

Comments
 (0)