[flow] Eliminate usage of global React types in ReactNativeTypes.js (#32330)

This commit is contained in:
Sam Zhou 2025-02-20 12:42:33 -05:00 committed by GitHub
parent 885532c124
commit 70f1d766e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -9,7 +9,13 @@
* @flow strict
*/
import type {ElementRef, ElementType, MixedElement} from 'react';
import type {
Component as ReactComponent,
ElementRef,
ElementType,
MixedElement,
RefSetter,
} from 'react';
// $FlowFixMe[nonstrict-import] TODO(@rubennorte)
import {type PublicRootInstance} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
@ -135,7 +141,7 @@ declare const ensureNativeMethodsAreSynced: NativeMethods;
export type HostInstance = NativeMethods;
export type HostComponent<Config: {...}> = component(
ref: React$RefSetter<HostInstance>,
ref: RefSetter<HostInstance>,
...Config
);
@ -188,7 +194,8 @@ export type RenderRootOptions = {
errorInfo: {
+componentStack?: ?string,
// $FlowFixMe[unclear-type] unknown props and state.
+errorBoundary?: ?React$Component<any, any>,
// $FlowFixMe[value-as-type] Component in react repo is any-typed, but it will be well typed externally.
+errorBoundary?: ?ReactComponent<any, any>,
},
) => void,
onRecoverableError?: (

View File

@ -17,6 +17,7 @@ export type Key = React$Key;
export type Node = React$Node;
export type Context<T> = React$Context<T>;
export type Portal = React$Portal;
export type RefSetter<-I> = React$RefSetter<I>;
export type ElementProps<C> = React$ElementProps<C>;
export type ElementConfig<C> = React$ElementConfig<C>;
export type ElementRef<C> = React$ElementRef<C>;