Skip to content

Commit aeb95e4

Browse files
authored
[flow] Eliminate usage of global React types in ReactNativeTypes.js
1 parent 8759c5c commit aeb95e4

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

1420
export type MeasureOnSuccessCallback = (
1521
x: number,
@@ -133,7 +139,7 @@ declare const ensureNativeMethodsAreSynced: NativeMethods;
133139

134140
export type HostInstance = NativeMethods;
135141
export type HostComponent<Config: {...}> = component(
136-
ref: React$RefSetter<HostInstance>,
142+
ref: RefSetter<HostInstance>,
137143
...Config
138144
);
139145

@@ -185,7 +191,8 @@ export type RenderRootOptions = {
185191
errorInfo: {
186192
+componentStack?: ?string,
187193
// $FlowFixMe[unclear-type] unknown props and state.
188-
+errorBoundary?: ?React$Component<any, any>,
194+
// $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
195+
+errorBoundary?: ?ReactComponent<any, any>,
189196
},
190197
) => void,
191198
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)