Skip to content

Commit

Permalink
[flow] Eliminate usage of global React types in ReactNativeTypes.js (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Feb 20, 2025
1 parent 885532c commit 70f1d76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
);

Expand Down Expand Up @@ -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?: (
Expand Down
1 change: 1 addition & 0 deletions packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down

0 comments on commit 70f1d76

Please sign in to comment.