From 55a3c1c88733df09826a31183d2bab1ff64acee7 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Sat, 23 May 2026 06:38:15 -0700 Subject: [PATCH 1/2] Add *Instance type exports for all built-in components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Add a publicly exported `*Instance` type for every built-in component in `index.js.flow`, giving consumers a consistent way to type refs for any React Native component. Affects the Strict TypeScript API (opt-in generated TS types) only. #### Motivation + RFC Draft implementation for the recommended approach in https://github.com/react-native-community/discussions-and-proposals/pull/1003. Alternative to https://github.com/facebook/react-native/pull/56673. #### New types | Component | Instance Type | Type Value | |---|---|---| | `ActivityIndicator` | `ActivityIndicatorInstance` | `HostInstance` | | `Button` | `ButtonInstance` | `ButtonRef` (platform-dependent) | | `DrawerLayoutAndroid` | `DrawerLayoutAndroidInstance` | `DrawerLayoutAndroidMethods` | | `FlatList` | `FlatListInstance` | `FlatList<>` | | `Image` | `ImageInstance` | `HostInstance` | | `ImageBackground` | `ImageBackgroundInstance` | `ImageBackground` (class) | | `KeyboardAvoidingView` | `KeyboardAvoidingViewInstance` | `KeyboardAvoidingView` (class) | | `Modal` | `ModalInstance` | `HostInstance` | | `Pressable` | `PressableInstance` | `HostInstance` | | `ProgressBarAndroid` | `ProgressBarAndroidInstance` | `HostInstance` | | `RefreshControl` | `RefreshControlInstance` | `RefreshControl` (class) | | `SafeAreaView` | `SafeAreaViewInstance` | `HostInstance` | | `ScrollView` | `ScrollViewInstance` | `extends HostInstance, ScrollViewImperativeMethods` | | `SectionList` | `SectionListInstance` | `SectionList<>` | | `StatusBar` | `StatusBarInstance` | `StatusBar` (class) | | `Switch` | `SwitchInstance` | `HostInstance` | | `Text` | `TextInstance` | `HostInstance` | | `TextInput` | `TextInputInstance` | `extends ReactNativeElement` (existing) | | `TouchableHighlight` | `TouchableHighlightInstance` | `HostInstance` | | `TouchableNativeFeedback` | `TouchableNativeFeedbackInstance` | `TouchableNativeFeedback` (class) | | `TouchableOpacity` | `TouchableOpacityInstance` | `HostInstance` | | `View` | `ViewInstance` | `HostInstance` | | `VirtualizedList` | `VirtualizedListInstance` | `React.ElementRef` | | `VirtualizedSectionList` | `VirtualizedSectionListInstance` | `React.ElementRef` | #### Renames - `PublicScrollViewInstance` → `ScrollViewInstance` (old name kept as deprecated alias; internal usages in `ScrollView.js` and `FlatList.js` updated) - `PublicModalInstance` → `ModalInstance` (old name kept as deprecated alias) #### Skipped (no ref support) `InputAccessoryView`, `experimental_LayoutConformance`, `TouchableWithoutFeedback`, `Touchable` (namespace) Changelog: [General][Added] - **Strict TypeScript API**: Add `*Instance` ref types for all built-in components Differential Revision: D106144383 --- .../ActivityIndicator/ActivityIndicator.js | 3 + .../Libraries/Components/Button.js | 2 + .../DrawerLayoutAndroid.android.js | 2 + .../DrawerAndroid/DrawerLayoutAndroid.ios.js | 2 + .../DrawerAndroid/DrawerLayoutAndroidTypes.js | 2 + .../Keyboard/KeyboardAvoidingView.js | 2 + .../Components/Pressable/Pressable.js | 3 + .../ProgressBarAndroid.android.js | 3 + .../ProgressBarAndroid/ProgressBarAndroid.js | 3 + .../RefreshControl/RefreshControl.js | 2 + .../Components/SafeAreaView/SafeAreaView.js | 3 + .../Components/ScrollView/ScrollView.js | 46 ++++----- .../Components/StatusBar/StatusBar.js | 2 + .../Libraries/Components/Switch/Switch.js | 3 + .../Components/TextInput/TextInput.js | 1 + .../Touchable/TouchableHighlight.js | 3 + .../Touchable/TouchableNativeFeedback.js | 2 + .../Components/Touchable/TouchableOpacity.js | 3 + .../Libraries/Components/View/View.js | 3 + .../Libraries/Image/Image.android.js | 2 + .../react-native/Libraries/Image/Image.ios.js | 2 + .../Libraries/Image/ImageBackground.js | 2 + .../Libraries/Image/ImageTypes.flow.js | 2 + .../react-native/Libraries/Lists/FlatList.js | 6 +- .../Libraries/Lists/SectionList.js | 2 + .../Libraries/Lists/VirtualizedList.js | 3 + .../Libraries/Lists/VirtualizedSectionList.js | 4 + .../react-native/Libraries/Modal/Modal.js | 5 +- packages/react-native/Libraries/Text/Text.js | 3 + packages/react-native/ReactNativeApi.d.ts | 97 ++++++++++++++----- packages/react-native/index.js.flow | 53 ++++++++-- 31 files changed, 210 insertions(+), 61 deletions(-) diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 28bc1886ee00..d2d079c1891d 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -10,8 +10,11 @@ 'use strict'; import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from '../View/ViewPropTypes'; +export type ActivityIndicatorInstance = HostInstance; + import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet'; import Platform from '../../Utilities/Platform'; import View from '../View/View'; diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index 40a926d8ac15..f8aa7ea3e891 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -286,6 +286,8 @@ const NativeTouchable: type ButtonRef = React.ElementRef; +export type ButtonInstance = ButtonRef; + const Button: component( ref?: React.RefSetter, ...props: ButtonProps diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index bde8466c0b8d..64bf5165c524 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -302,4 +302,6 @@ const styles = StyleSheet.create({ }, }); +export type DrawerLayoutAndroidInstance = DrawerLayoutAndroid; + export default DrawerLayoutAndroid as $FlowFixMe; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js index cfaf89fea761..4d70f35bfac5 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js @@ -12,4 +12,6 @@ import DrawerLayoutAndroidFallback from './DrawerLayoutAndroidFallback'; +export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidFallback; + export default DrawerLayoutAndroidFallback; diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js index e100c6006eed..26cc85563a2d 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js @@ -136,3 +136,5 @@ export interface DrawerLayoutAndroidMethods { ): void; setNativeProps(nativeProps: Object): void; } + +export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods; diff --git a/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js index 5a829fc9d457..87ac6de0665a 100644 --- a/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -298,4 +298,6 @@ class KeyboardAvoidingView extends React.Component< } } +export type KeyboardAvoidingViewInstance = KeyboardAvoidingView; + export default KeyboardAvoidingView; diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index a1fd57921ee3..bb631c321c2a 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -8,6 +8,7 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type { GestureResponderEvent, @@ -16,6 +17,8 @@ import type { } from '../../Types/CoreEventTypes'; import type {ViewProps} from '../View/ViewPropTypes'; +export type PressableInstance = HostInstance; + import {PressabilityDebugView} from '../../Pressability/PressabilityDebug'; import usePressability from '../../Pressability/usePressability'; import {type RectOrSize} from '../../StyleSheet/Rect'; diff --git a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index aadcb2aee3ec..3c5f0e68e98a 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -8,10 +8,13 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes'; import ProgressBarAndroidNativeComponent from './ProgressBarAndroidNativeComponent'; +export type ProgressBarAndroidInstance = HostInstance; + const React = require('react'); export type {ProgressBarAndroidProps}; diff --git a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js index 447327cb6695..9a509e467862 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js @@ -10,11 +10,14 @@ 'use strict'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent'; import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes'; import Platform from '../../Utilities/Platform'; +export type ProgressBarAndroidInstance = HostInstance; + export type {ProgressBarAndroidProps}; // A utility type to preserve the semantics of the union uses in the definition diff --git a/packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js b/packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js index 184fcb9eb3f5..57e75e1b4df0 100644 --- a/packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js +++ b/packages/react-native/Libraries/Components/RefreshControl/RefreshControl.js @@ -205,4 +205,6 @@ class RefreshControl extends React.Component { }; } +export type RefreshControlInstance = RefreshControl; + export default RefreshControl; diff --git a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js index 34097b8ea3b4..1dd49d3afd88 100644 --- a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -8,8 +8,11 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from '../View/ViewPropTypes'; +export type SafeAreaViewInstance = HostInstance; + import Platform from '../../Utilities/Platform'; import View from '../View/View'; import * as React from 'react'; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index 1911429065ba..4f3a4fe3bb8f 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -139,7 +139,7 @@ export interface ScrollViewImperativeMethods { readonly getScrollableNode: () => ?number; readonly getInnerViewNode: () => ?number; readonly getInnerViewRef: () => InnerViewInstance | null; - readonly getNativeScrollRef: () => PublicScrollViewInstance | null; + readonly getNativeScrollRef: () => ScrollViewInstance | null; readonly scrollTo: ( options?: ScrollViewScrollToOptions | number, deprecatedX?: number, @@ -167,10 +167,13 @@ export interface ScrollViewImperativeMethods { export type DecelerationRateType = 'fast' | 'normal' | number; export type ScrollResponderType = ScrollViewImperativeMethods; -export interface PublicScrollViewInstance +export interface ScrollViewInstance extends HostInstance, ScrollViewImperativeMethods {} +/** @deprecated Use ScrollViewInstance instead */ +export type PublicScrollViewInstance = ScrollViewInstance; + type InnerViewInstance = React.ElementRef; export type ScrollViewPropsIOS = Readonly<{ @@ -677,7 +680,7 @@ type ScrollViewBaseProps = Readonly<{ * all of ScrollView's public methods, in addition to native methods like * measure, measureLayout, etc. */ - scrollViewRef?: React.RefSetter, + scrollViewRef?: React.RefSetter, }>; /** @build-types emit-as-interface Nativewind compatibility */ @@ -874,7 +877,7 @@ class ScrollView extends React.Component { getNativeScrollRef: ScrollViewImperativeMethods['getNativeScrollRef'] = () => { // Object.assign in _scrollView's mutator augments nativeInstance in place, - // so it is already a PublicScrollViewInstance at runtime. + // so it is already a ScrollViewInstance at runtime. // $FlowFixMe[incompatible-type] return this._scrollView.nativeInstance; }; @@ -1170,7 +1173,7 @@ class ScrollView extends React.Component { (instance: InnerViewInstance): InnerViewInstance => instance, ); - _scrollView: RefForwarder = + _scrollView: RefForwarder = createRefForwarder(nativeInstance => { // This is a hack. Ideally we would forwardRef to the underlying // host component. However, since ScrollView has it's own methods that can be @@ -1183,22 +1186,19 @@ class ScrollView extends React.Component { // $FlowFixMe[prop-missing] - Known issue with appending custom methods. // $FlowFixMe[incompatible-type] // $FlowFixMe[unsafe-object-assign] - const publicInstance: PublicScrollViewInstance = Object.assign( - nativeInstance, - { - getScrollResponder: this.getScrollResponder, - getScrollableNode: this.getScrollableNode, - getInnerViewNode: this.getInnerViewNode, - getInnerViewRef: this.getInnerViewRef, - getNativeScrollRef: this.getNativeScrollRef, - scrollTo: this.scrollTo, - scrollToEnd: this.scrollToEnd, - flashScrollIndicators: this.flashScrollIndicators, - scrollResponderZoomTo: this.scrollResponderZoomTo, - scrollResponderScrollNativeHandleToKeyboard: - this.scrollResponderScrollNativeHandleToKeyboard, - }, - ); + const publicInstance: ScrollViewInstance = Object.assign(nativeInstance, { + getScrollResponder: this.getScrollResponder, + getScrollableNode: this.getScrollableNode, + getInnerViewNode: this.getInnerViewNode, + getInnerViewRef: this.getInnerViewRef, + getNativeScrollRef: this.getNativeScrollRef, + scrollTo: this.scrollTo, + scrollToEnd: this.scrollToEnd, + flashScrollIndicators: this.flashScrollIndicators, + scrollResponderZoomTo: this.scrollResponderZoomTo, + scrollResponderScrollNativeHandleToKeyboard: + this.scrollResponderScrollNativeHandleToKeyboard, + }); return publicInstance; }); @@ -1935,13 +1935,13 @@ function createRefForwarder( // component and we need to map `ref` to a differently named prop. This can be // removed when `ScrollView` is a functional component. const ScrollViewWrapper: component( - ref?: React.RefSetter, + ref?: React.RefSetter, ...props: ScrollViewProps ) = function Wrapper({ ref, ...props }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...ScrollViewProps, }): React.Node { return ref == null ? ( diff --git a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js index 5df3131bdcf0..5f63e0f03eb8 100644 --- a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js +++ b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js @@ -509,4 +509,6 @@ class StatusBar extends React.Component { } } +export type StatusBarInstance = StatusBar; + export default StatusBar; diff --git a/packages/react-native/Libraries/Components/Switch/Switch.js b/packages/react-native/Libraries/Components/Switch/Switch.js index 790cf7716ff9..767d5e592270 100644 --- a/packages/react-native/Libraries/Components/Switch/Switch.js +++ b/packages/react-native/Libraries/Components/Switch/Switch.js @@ -8,11 +8,14 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type {NativeSyntheticEvent} from '../../Types/CoreEventTypes'; import type {AccessibilityState} from '../View/ViewAccessibility'; import type {ViewProps} from '../View/ViewPropTypes'; +export type SwitchInstance = HostInstance; + import StyleSheet from '../../StyleSheet/StyleSheet'; import Platform from '../../Utilities/Platform'; import useMergeRefs from '../../Utilities/useMergeRefs'; diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index adca4e337572..0206446c9262 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -117,6 +117,7 @@ export type { TextInputKeyPressEvent, TextInputProps, TextInputSelectionChangeEvent, + TextInputInstance, TextInputSubmitEditingEvent, }; diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js index 9dc8b606a0f4..ecd6f63204ba 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js @@ -8,10 +8,13 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ColorValue} from '../../StyleSheet/StyleSheet'; import type {AccessibilityState} from '../View/ViewAccessibility'; import type {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback'; +export type TouchableHighlightInstance = HostInstance; + import View from '../../Components/View/View'; import Pressability, { type PressabilityConfig, diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js b/packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js index 31943e6f6781..ad3452621c02 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -409,4 +409,6 @@ const getBackgroundProp = TouchableNativeFeedback.displayName = 'TouchableNativeFeedback'; +export type TouchableNativeFeedbackInstance = TouchableNativeFeedback; + export default TouchableNativeFeedback; diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js index 72d7ad49f2f9..852603410cb0 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js @@ -8,9 +8,12 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback'; +export type TouchableOpacityInstance = HostInstance; + import Animated from '../../Animated/Animated'; import Easing from '../../Animated/Easing'; import Pressability, { diff --git a/packages/react-native/Libraries/Components/View/View.js b/packages/react-native/Libraries/Components/View/View.js index c2486bde14a5..9bc8acab1e90 100644 --- a/packages/react-native/Libraries/Components/View/View.js +++ b/packages/react-native/Libraries/Components/View/View.js @@ -8,10 +8,13 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from './ViewPropTypes'; import TextAncestorContext from '../../Text/TextAncestorContext'; import ViewNativeComponent from './ViewNativeComponent'; + +export type ViewInstance = HostInstance; import * as React from 'react'; import {use} from 'react'; diff --git a/packages/react-native/Libraries/Image/Image.android.js b/packages/react-native/Libraries/Image/Image.android.js index 4ca519311030..da729075676f 100644 --- a/packages/react-native/Libraries/Image/Image.android.js +++ b/packages/react-native/Libraries/Image/Image.android.js @@ -14,6 +14,8 @@ import type {RootTag} from '../Types/RootTagTypes'; import type {ImageProps} from './ImageProps'; import type {AbstractImageAndroid, ImageAndroid} from './ImageTypes.flow'; +export type ImageInstance = HostInstance; + import flattenStyle from '../StyleSheet/flattenStyle'; import StyleSheet from '../StyleSheet/StyleSheet'; import ImageAnalyticsTagContext from './ImageAnalyticsTagContext'; diff --git a/packages/react-native/Libraries/Image/Image.ios.js b/packages/react-native/Libraries/Image/Image.ios.js index 0580736dac42..6a41f4dccd5c 100644 --- a/packages/react-native/Libraries/Image/Image.ios.js +++ b/packages/react-native/Libraries/Image/Image.ios.js @@ -15,6 +15,8 @@ import type {ImageProps} from './ImageProps'; import type {AbstractImageIOS, ImageIOS} from './ImageTypes.flow'; import type {ImageSize} from './NativeImageLoaderAndroid'; +export type ImageInstance = HostInstance; + import {createRootTag} from '../ReactNative/RootTag'; import flattenStyle from '../StyleSheet/flattenStyle'; import StyleSheet from '../StyleSheet/StyleSheet'; diff --git a/packages/react-native/Libraries/Image/ImageBackground.js b/packages/react-native/Libraries/Image/ImageBackground.js index 26af42951df4..628c7cbebd4c 100644 --- a/packages/react-native/Libraries/Image/ImageBackground.js +++ b/packages/react-native/Libraries/Image/ImageBackground.js @@ -105,4 +105,6 @@ class ImageBackground extends React.Component { } } +export type ImageBackgroundInstance = ImageBackground; + export default ImageBackground; diff --git a/packages/react-native/Libraries/Image/ImageTypes.flow.js b/packages/react-native/Libraries/Image/ImageTypes.flow.js index 6058d6367bd7..24b6332889b6 100644 --- a/packages/react-native/Libraries/Image/ImageTypes.flow.js +++ b/packages/react-native/Libraries/Image/ImageTypes.flow.js @@ -10,6 +10,8 @@ import type {HostInstance} from '../..'; import type {RootTag} from '../Types/RootTagTypes'; + +export type ImageInstance = HostInstance; import type {ResolvedAssetSource} from './AssetSourceResolver'; import type {ImageProps as ImagePropsType} from './ImageProps'; import type {ImageSource} from './ImageSource'; diff --git a/packages/react-native/Libraries/Lists/FlatList.js b/packages/react-native/Libraries/Lists/FlatList.js index 43256b3f79db..ff4563be2406 100644 --- a/packages/react-native/Libraries/Lists/FlatList.js +++ b/packages/react-native/Libraries/Lists/FlatList.js @@ -8,7 +8,7 @@ * @format */ -import type {PublicScrollViewInstance} from '../Components/ScrollView/ScrollView'; +import type {ScrollViewInstance} from '../Components/ScrollView/ScrollView'; import type {ViewStyleProp} from '../StyleSheet/StyleSheet'; import type { ListRenderItem, @@ -398,7 +398,7 @@ class FlatList extends React.PureComponent> { /** * Provides a reference to the underlying host component */ - getNativeScrollRef(): ?PublicScrollViewInstance { + getNativeScrollRef(): ?ScrollViewInstance { if (this._listRef) { return this._listRef.getScrollRef(); } @@ -706,4 +706,6 @@ const styles = StyleSheet.create({ row: {flexDirection: 'row'}, }); +export type FlatListInstance = FlatList<>; + export default FlatList; diff --git a/packages/react-native/Libraries/Lists/SectionList.js b/packages/react-native/Libraries/Lists/SectionList.js index 27bd227006b2..489a5c932368 100644 --- a/packages/react-native/Libraries/Lists/SectionList.js +++ b/packages/react-native/Libraries/Lists/SectionList.js @@ -265,3 +265,5 @@ export default class SectionList< this._wrapperListRef = ref; }; } + +export type SectionListInstance = SectionList<>; diff --git a/packages/react-native/Libraries/Lists/VirtualizedList.js b/packages/react-native/Libraries/Lists/VirtualizedList.js index df18a2742993..b095a35ffafd 100644 --- a/packages/react-native/Libraries/Lists/VirtualizedList.js +++ b/packages/react-native/Libraries/Lists/VirtualizedList.js @@ -11,11 +11,14 @@ 'use strict'; import VirtualizedLists from '@react-native/virtualized-lists'; +import * as React from 'react'; type VirtualizedListType = typeof VirtualizedLists.VirtualizedList; const VirtualizedListComponent: VirtualizedListType = VirtualizedLists.VirtualizedList; +export type VirtualizedListInstance = React.ElementRef; + export type { ListRenderItemInfo, ListRenderItem, diff --git a/packages/react-native/Libraries/Lists/VirtualizedSectionList.js b/packages/react-native/Libraries/Lists/VirtualizedSectionList.js index a4ea79b997b7..a8b9799b18c1 100644 --- a/packages/react-native/Libraries/Lists/VirtualizedSectionList.js +++ b/packages/react-native/Libraries/Lists/VirtualizedSectionList.js @@ -11,12 +11,16 @@ 'use strict'; import VirtualizedLists from '@react-native/virtualized-lists'; +import * as React from 'react'; type VirtualizedSectionListType = typeof VirtualizedLists.VirtualizedSectionList; const VirtualizedSectionList: VirtualizedSectionListType = VirtualizedLists.VirtualizedSectionList; +export type VirtualizedSectionListInstance = + React.ElementRef; + export type { SectionBase, ScrollToLocationParamsType, diff --git a/packages/react-native/Libraries/Modal/Modal.js b/packages/react-native/Libraries/Modal/Modal.js index 80a652ff80c1..a4ac0e387c4e 100644 --- a/packages/react-native/Libraries/Modal/Modal.js +++ b/packages/react-native/Libraries/Modal/Modal.js @@ -36,7 +36,10 @@ type ModalEventDefinitions = { modalDismissed: [{modalID: number}], }; -export type PublicModalInstance = HostInstance; +export type ModalInstance = HostInstance; + +/** @deprecated Use ModalInstance instead */ +export type PublicModalInstance = ModalInstance; const ModalEventEmitter = Platform.OS === 'ios' && NativeModalManager != null diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index 8e7b29cb6096..204b231f4a17 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -8,12 +8,15 @@ * @format */ +import type {HostInstance} from '../../src/private/types/HostInstance'; import type {TextStyleProp} from '../StyleSheet/StyleSheet'; import type {____TextStyle_Internal as TextStyleInternal} from '../StyleSheet/StyleSheetTypes'; import type {GestureResponderEvent} from '../Types/CoreEventTypes'; import type {NativeTextProps} from './TextNativeComponent'; import type {PressRetentionOffset, TextProps} from './TextProps'; +export type TextInstance = HostInstance; + import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags'; import * as PressabilityDebug from '../Pressability/PressabilityDebug'; import usePressability from '../Pressability/usePressability'; diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index abd52ddb4370..fb682da7fd11 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<08dd369849273136812ea5edbda6e1df>> + * @generated SignedSource<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -401,7 +401,7 @@ declare const ScrollView: typeof ScrollViewWrapper & ScrollViewComponentStatics declare const ScrollViewContext_default: React.Context declare const ScrollViewWrapper: ( props: ScrollViewProps & { - ref?: React.Ref + ref?: React.Ref }, ) => React.ReactNode declare const sequence: typeof $$AnimatedImplementation.sequence @@ -1202,6 +1202,7 @@ declare type ActiveCallback = ( gestureState: PanResponderGestureState, ) => boolean declare type ActivityIndicator = typeof ActivityIndicator +declare type ActivityIndicatorInstance = HostInstance declare type ActivityIndicatorIOSProps = { readonly hidesWhenStopped?: boolean } @@ -1760,6 +1761,7 @@ declare type Builtin = ( ...$$REST$$: ReadonlyArray ) => Date | Error | RegExp | unknown declare type Button = typeof Button +declare type ButtonInstance = ButtonRef declare interface ButtonProps { readonly accessibilityActions?: ReadonlyArray readonly accessibilityHint?: string @@ -2097,6 +2099,7 @@ declare class DrawerLayoutAndroid_default render(): React.ReactNode setNativeProps(nativeProps: Object): void } +declare type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods declare interface DrawerLayoutAndroidMethods { blur(): void closeDrawer(): void @@ -2330,7 +2333,7 @@ declare class FlatList extends React.PureComponent< componentDidUpdate(prevProps: FlatListProps): void constructor(props: FlatListProps) flashScrollIndicators(): void - getNativeScrollRef(): null | PublicScrollViewInstance | undefined + getNativeScrollRef(): null | ScrollViewInstance | undefined getScrollableNode(): any getScrollResponder(): null | ScrollResponderType | undefined recordInteraction(): void @@ -2360,6 +2363,7 @@ declare class FlatList extends React.PureComponent< } declare type FlatListBaseProps = RequiredFlatListProps & OptionalFlatListProps +declare type FlatListInstance = FlatList declare interface FlatListProps extends Readonly< Omit< @@ -2541,6 +2545,7 @@ declare class ImageBackground extends React.Component { render(): React.ReactNode setNativeProps(props: {}): void } +declare type ImageBackgroundInstance = ImageBackground declare interface ImageBackgroundProps extends Readonly> { readonly children?: React.ReactNode @@ -2591,6 +2596,7 @@ declare type ImageErrorEvent = NativeSyntheticEvent< declare type ImageErrorEventData = { error: string } +declare type ImageInstance = HostInstance declare type ImageIOS = AbstractImageIOS & ImageComponentStaticsIOS declare type ImageLoadEvent = NativeSyntheticEvent> declare type ImageLoadEventData = { @@ -2870,6 +2876,7 @@ declare class KeyboardAvoidingView extends React.Component< constructor(props: KeyboardAvoidingViewProps) render(): React.ReactNode } +declare type KeyboardAvoidingViewInstance = KeyboardAvoidingView declare interface KeyboardAvoidingViewProps extends Readonly { readonly behavior?: "height" | "padding" | "position" readonly contentContainerStyle?: ViewStyleProp @@ -3176,6 +3183,7 @@ declare interface ModalBaseProps { transparent?: boolean visible?: boolean } +declare type ModalInstance = HostInstance declare type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid & @@ -3838,6 +3846,7 @@ declare type PressableBaseProps = { readonly testID?: string readonly testOnly_pressed?: boolean } +declare type PressableInstance = HostInstance declare interface PressableProps extends Readonly< Omit & PressableBaseProps @@ -3863,6 +3872,7 @@ declare type ProgressBarAndroidBaseProps = { readonly color?: ColorValue readonly testID?: string } +declare type ProgressBarAndroidInstance = HostInstance declare type ProgressBarAndroidNativeComponentType = typeof $$ProgressBarAndroidNativeComponent declare type ProgressBarAndroidProps = @@ -3880,13 +3890,10 @@ declare type PromiseTask = { name: string gen: () => Promise } -declare type PublicModalInstance = HostInstance +declare type PublicModalInstance = ModalInstance declare type PublicRootInstance = symbol & { __PublicRootInstance__: string } -declare interface PublicScrollViewInstance - extends HostInstance, - ScrollViewImperativeMethods {} declare type PublicTextInstance = ReturnType declare interface PushNotification { finish(result: string): void @@ -4173,6 +4180,7 @@ declare type RefreshControlBaseProps = { readonly progressViewOffset?: number readonly refreshing: boolean } +declare type RefreshControlInstance = RefreshControl declare interface RefreshControlProps extends Readonly< ViewProps & @@ -4405,6 +4413,7 @@ declare type Runnables = { [appKey: string]: Runnable } declare type SafeAreaView = typeof SafeAreaView +declare type SafeAreaViewInstance = HostInstance declare type ScaledSize = DisplayMetrics declare type ScheduleLocalNotificationDetails = PresentLocalNotificationDetails & { @@ -4450,7 +4459,7 @@ declare type ScrollViewBaseProps = { readonly removeClippedSubviews?: boolean readonly scrollEnabled?: boolean readonly scrollEventThrottle?: number - readonly scrollViewRef?: React.Ref + readonly scrollViewRef?: React.Ref readonly showsVerticalScrollIndicator?: boolean readonly snapToAlignment?: "center" | "end" | "start" readonly snapToEnd?: boolean @@ -4476,7 +4485,7 @@ declare interface ScrollViewImperativeMethods { readonly flashScrollIndicators: () => void readonly getInnerViewNode: () => number | undefined readonly getInnerViewRef: () => InnerViewInstance | null - readonly getNativeScrollRef: () => null | PublicScrollViewInstance + readonly getNativeScrollRef: () => null | ScrollViewInstance readonly getScrollableNode: () => number | undefined readonly getScrollResponder: () => ScrollResponderType readonly scrollResponderScrollNativeHandleToKeyboard: ( @@ -4503,6 +4512,9 @@ declare interface ScrollViewImperativeMethods { options?: ScrollViewScrollToOptions | undefined, ) => void } +declare interface ScrollViewInstance + extends HostInstance, + ScrollViewImperativeMethods {} declare interface ScrollViewProps extends Readonly< ViewProps & @@ -4610,6 +4622,7 @@ declare type SectionListData< | (Readonly> & SectionT) | (SectionBase & SectionT) | SectionT +declare type SectionListInstance = SectionList declare interface SectionListProps extends Readonly< Omit< @@ -4951,6 +4964,7 @@ declare type StatusBarBaseProps = { readonly barStyle?: "dark-content" | "default" | "light-content" readonly hidden?: boolean } +declare type StatusBarInstance = StatusBar declare type StatusBarProps = Readonly< StatusBarPropsAndroid & StatusBarPropsIOS & StatusBarBaseProps > @@ -5000,6 +5014,7 @@ declare type SwitchChangeEventData = { readonly target: number readonly value: boolean } +declare type SwitchInstance = HostInstance declare type SwitchNativeProps = Readonly< ViewProps & { disabled?: WithDefault @@ -5386,6 +5401,7 @@ declare type TextInputSubmitEditingEventData = Readonly< } > declare type TextInputType = InternalTextInput & TextInputComponentStatics +declare type TextInstance = HostInstance declare type TextLayoutEvent = NativeSyntheticEvent declare type TextLayoutEventData = { readonly lines: Array @@ -5477,6 +5493,7 @@ declare type TouchableHighlightBaseProps = { readonly testOnly_pressed?: boolean readonly underlayColor?: ColorValue } +declare type TouchableHighlightInstance = HostInstance declare interface TouchableHighlightProps extends Readonly< TouchableWithoutFeedbackProps & @@ -5520,6 +5537,7 @@ declare class TouchableNativeFeedback extends React.Component< componentWillUnmount(): void render(): React.ReactNode } +declare type TouchableNativeFeedbackInstance = TouchableNativeFeedback declare type TouchableNativeFeedbackProps = Readonly< TouchableWithoutFeedbackProps & TouchableNativeFeedbackTVProps & { @@ -5557,6 +5575,7 @@ declare type TouchableOpacityBaseProps = { readonly hostRef?: React.Ref> readonly style?: Animated.WithAnimatedValue } +declare type TouchableOpacityInstance = HostInstance declare type TouchableOpacityProps = Readonly< TouchableWithoutFeedbackProps & TouchableOpacityTVProps & @@ -5794,6 +5813,7 @@ declare type ViewConfig = { readonly uiViewClassName: string readonly validAttributes: AttributeConfiguration } +declare type ViewInstance = HostInstance declare interface ViewProps extends Readonly< DirectEventProps & @@ -5879,12 +5899,15 @@ declare function VirtualizedListContextResetter($$PARAM_0$$: { }): React.ReactNode declare type VirtualizedListContextResetterT = typeof VirtualizedListContextResetter +declare type VirtualizedListInstance = React.ComponentRef declare type VirtualizedListProps = ScrollViewProps & RequiredVirtualizedListProps & OptionalVirtualizedListProps declare type VirtualizedListT = typeof VirtualizedList_default declare type VirtualizedListType = typeof $$index.VirtualizedList declare type VirtualizedSectionList = typeof VirtualizedSectionList +declare type VirtualizedSectionListInstance = + React.ComponentRef declare type VirtualizedSectionListProps< ItemT, SectionT = DefaultVirtualizedSectionT, @@ -6000,6 +6023,7 @@ export { ActionSheetIOS, // b558559e ActionSheetIOSOptions, // 1756eb5a ActivityIndicator, // f06b0687 + ActivityIndicatorInstance, // 6ac360b7 ActivityIndicatorProps, // 5e976856 Alert, // 5bf12165 AlertButton, // bf1a3b60 @@ -6007,7 +6031,7 @@ export { AlertOptions, // a0cdac0f AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // 1a47480c + Animated, // dac556c2 AppConfig, // ce4209a7 AppRegistry, // 5edf0524 AppState, // 12012be5 @@ -6020,6 +6044,7 @@ export { BlurEvent, // e6151a1f BoxShadowValue, // b679703f Button, // 869e5a89 + ButtonInstance, // c02f61d2 ButtonProps, // 349967e6 Clipboard, // 41addb89 CodegenTypes, // 0b8108a8 @@ -6039,6 +6064,7 @@ export { DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb DrawerLayoutAndroid, // eb4bcfa5 + DrawerLayoutAndroidInstance, // c0694352 DrawerLayoutAndroidProps, // 1ddb208e DrawerSlideEvent, // 0256d35a DropShadowValue, // e9df2606 @@ -6054,8 +6080,9 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // e47faa4e - FlatListProps, // 22cacca0 + FlatList, // f29e5bae + FlatListInstance, // d705d4fe + FlatListProps, // 9ac3710e FocusEvent, // 62fc1eb8 FontVariant, // 7c7558bb GestureResponderEvent, // f693e9a5 @@ -6069,8 +6096,10 @@ export { IgnorePattern, // ec6f6ece Image, // 1891541a ImageBackground, // cf95f60b + ImageBackgroundInstance, // 811a9a31 ImageBackgroundProps, // c68c896d ImageErrorEvent, // d3ee606e + ImageInstance, // 2c122c2d ImageLoadEvent, // 6b547ea5 ImageProgressEventIOS, // 4c866a82 ImageProps, // 801d1e1c @@ -6094,6 +6123,7 @@ export { KeyUpEvent, // bc6bd87b Keyboard, // 49414c97 KeyboardAvoidingView, // c8c29c8d + KeyboardAvoidingViewInstance, // 63a460fc KeyboardAvoidingViewProps, // 4114f649 KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 @@ -6119,9 +6149,10 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // bdd9bb3f - ModalBaseProps, // 3cca97dc - ModalProps, // aa4211df + Modal, // 37f44aff + ModalBaseProps, // 17e2ed28 + ModalInstance, // fbd32990 + ModalProps, // 32ff7e1c ModalPropsAndroid, // 515fb173 ModalPropsIOS, // 144bbc95 ModeChangeEvent, // a5e9864f @@ -6161,10 +6192,12 @@ export { PressabilityEventHandlers, // 3e6c0f56 Pressable, // 0241ba70 PressableAndroidRippleConfig, // ee32eaca + PressableInstance, // c93aef84 PressableProps, // a9048420 PressableStateCallbackType, // 9af36561 ProcessedColorValue, // 33f74304 ProgressBarAndroid, // 00fcd180 + ProgressBarAndroidInstance, // de8a2c3a ProgressBarAndroidProps, // f59f8f03 PromiseTask, // 5102c862 PublicRootInstance, // 8040afd7 @@ -6175,6 +6208,7 @@ export { Rationale, // 5df1b1c1 ReactNativeVersion, // abd76827 RefreshControl, // ed67a3b2 + RefreshControlInstance, // c502c711 RefreshControlProps, // bfc35644 RefreshControlPropsAndroid, // 99f64c97 RefreshControlPropsIOS, // 72a36381 @@ -6188,20 +6222,23 @@ export { Runnable, // 594dd93a Runnables, // 4367c557 SafeAreaView, // a7cd92bb + SafeAreaViewInstance, // a9027869 ScaledSize, // 07e417c7 ScrollEvent, // 5d529218 - ScrollResponderType, // 197f0107 + ScrollResponderType, // 190f136e ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // 938178e6 - ScrollViewImperativeMethods, // 27f6b917 - ScrollViewProps, // d5d9f043 + ScrollView, // ba50902e + ScrollViewImperativeMethods, // ea8c81c5 + ScrollViewInstance, // e9ff1b20 + ScrollViewProps, // 038eaec5 ScrollViewPropsAndroid, // 44210553 ScrollViewPropsIOS, // b34b696c ScrollViewScrollToOptions, // 3313411e SectionBase, // b376bddc - SectionList, // 6b202d76 + SectionList, // 2a3caa23 SectionListData, // 119baf83 - SectionListProps, // 6bdbf0ef + SectionListInstance, // eb3accfa + SectionListProps, // 0c74fddf SectionListRenderItem, // 1fad0435 SectionListRenderItemInfo, // 745e1992 Separators, // 6a45f7e3 @@ -6215,6 +6252,7 @@ export { SimpleTask, // 0e619d11 StatusBar, // 5e08d563 StatusBarAnimation, // 7fd047e6 + StatusBarInstance, // 09bf1476 StatusBarProps, // 06c98add StatusBarStyle, // 986b2051 StyleProp, // fa0e9b4a @@ -6222,6 +6260,7 @@ export { SubmitBehavior, // c4ddf490 Switch, // 015be3f7 SwitchChangeEvent, // 63e9c50b + SwitchInstance, // 9fddadca SwitchProps, // 0dbf23ea Systrace, // 626d178c TVViewPropsIOS, // 330ce7b5 @@ -6229,27 +6268,32 @@ export { TaskProvider, // 266dedf2 Text, // 608149e8 TextContentType, // 239b3ecc - TextInput, // 3b7016bb + TextInput, // b541a946 TextInputAndroidProps, // 3f09ce49 TextInputChangeEvent, // 3ab11bb4 TextInputContentSizeChangeEvent, // f71f8571 TextInputEndEditingEvent, // e5f70633 TextInputFocusEvent, // 020507e6 TextInputIOSProps, // 0d05a855 + TextInputInstance, // a8cc5e25 TextInputKeyPressEvent, // 3924ad9b - TextInputProps, // 96c07405 + TextInputProps, // 910fb55d TextInputSelectionChangeEvent, // d4d10630 TextInputSubmitEditingEvent, // 22885c31 + TextInstance, // 9ac50c01 TextLayoutEvent, // 73ab173e TextProps, // 4c29419c TextStyle, // bb9b7a58 ToastAndroid, // 88a8969a Touchable, // da3239ee TouchableHighlight, // 49bbefe7 + TouchableHighlightInstance, // 96d47f78 TouchableHighlightProps, // f14a1131 TouchableNativeFeedback, // d89b59a8 + TouchableNativeFeedbackInstance, // beb58e1e TouchableNativeFeedbackProps, // a88ade2e TouchableOpacity, // 8d1b023b + TouchableOpacityInstance, // 09bc64ed TouchableOpacityProps, // 908e84b9 TouchableWithoutFeedback, // 71d446ec TouchableWithoutFeedbackProps, // e0c1c566 @@ -6260,15 +6304,18 @@ export { UTFSequence, // ad625158 Vibration, // 31e4bbf8 View, // 234d8db5 + ViewInstance, // 1a59bec1 ViewProps, // 6d644e8b ViewPropsAndroid, // ac650c5c ViewPropsIOS, // 58ee19bf ViewStyle, // 00a0f8fb VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e - VirtualizedListProps, // 9453ce86 + VirtualizedListInstance, // 423ee7c0 + VirtualizedListProps, // a9901686 VirtualizedSectionList, // 9fd9cd61 - VirtualizedSectionListProps, // 7a993da5 + VirtualizedSectionListInstance, // 12b706d5 + VirtualizedSectionListProps, // 90e14aed WrapperComponentProvider, // 9cf3844c codegenNativeCommands, // 628a7c0a codegenNativeComponent, // 2baac257 diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index 9f2eac497d63..b2f596090c86 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -22,21 +22,26 @@ // #region Components -export type {ActivityIndicatorProps} from './Libraries/Components/ActivityIndicator/ActivityIndicator'; +export type { + ActivityIndicatorInstance, + ActivityIndicatorProps, +} from './Libraries/Components/ActivityIndicator/ActivityIndicator'; export {default as ActivityIndicator} from './Libraries/Components/ActivityIndicator/ActivityIndicator'; -export type {ButtonProps} from './Libraries/Components/Button'; +export type {ButtonInstance, ButtonProps} from './Libraries/Components/Button'; export {default as Button} from './Libraries/Components/Button'; export type { + DrawerLayoutAndroidInstance, DrawerLayoutAndroidProps, DrawerSlideEvent, -} from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid'; +} from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes'; export {default as DrawerLayoutAndroid} from './Libraries/Components/DrawerAndroid/DrawerLayoutAndroid'; -export type {FlatListProps} from './Libraries/Lists/FlatList'; +export type {FlatListInstance, FlatListProps} from './Libraries/Lists/FlatList'; export {default as FlatList} from './Libraries/Lists/FlatList'; +export type {ImageInstance} from './Libraries/Image/ImageTypes.flow'; export type { ImageBackgroundProps, ImageErrorEvent, @@ -56,12 +61,16 @@ export type { ImageURISource, } from './Libraries/Image/ImageSource'; export {default as Image} from './Libraries/Image/Image'; +export type {ImageBackgroundInstance} from './Libraries/Image/ImageBackground'; export {default as ImageBackground} from './Libraries/Image/ImageBackground'; export type {InputAccessoryViewProps} from './Libraries/Components/TextInput/InputAccessoryView'; export {default as InputAccessoryView} from './Libraries/Components/TextInput/InputAccessoryView'; -export type {KeyboardAvoidingViewProps} from './Libraries/Components/Keyboard/KeyboardAvoidingView'; +export type { + KeyboardAvoidingViewInstance, + KeyboardAvoidingViewProps, +} from './Libraries/Components/Keyboard/KeyboardAvoidingView'; export {default as KeyboardAvoidingView} from './Libraries/Components/Keyboard/KeyboardAvoidingView'; export type {LayoutConformanceProps} from './Libraries/Components/LayoutConformance/LayoutConformance'; @@ -69,6 +78,7 @@ export {default as experimental_LayoutConformance} from './Libraries/Components/ export type { ModalBaseProps, + ModalInstance, ModalProps, ModalPropsAndroid, ModalPropsIOS, @@ -77,25 +87,32 @@ export {default as Modal} from './Libraries/Modal/Modal'; export type { PressableAndroidRippleConfig, + PressableInstance, PressableProps, PressableStateCallbackType, } from './Libraries/Components/Pressable/Pressable'; export {default as Pressable} from './Libraries/Components/Pressable/Pressable'; -export type {ProgressBarAndroidProps} from './Libraries/Components/ProgressBarAndroid/ProgressBarAndroid'; +export type { + ProgressBarAndroidInstance, + ProgressBarAndroidProps, +} from './Libraries/Components/ProgressBarAndroid/ProgressBarAndroid'; export {default as ProgressBarAndroid} from './Libraries/Components/ProgressBarAndroid/ProgressBarAndroid'; export type { + RefreshControlInstance, RefreshControlProps, RefreshControlPropsAndroid, RefreshControlPropsIOS, } from './Libraries/Components/RefreshControl/RefreshControl'; export {default as RefreshControl} from './Libraries/Components/RefreshControl/RefreshControl'; +export type {SafeAreaViewInstance} from './Libraries/Components/SafeAreaView/SafeAreaView'; export {default as SafeAreaView} from './Libraries/Components/SafeAreaView/SafeAreaView'; export type { ScrollViewImperativeMethods, + ScrollViewInstance, ScrollViewScrollToOptions, ScrollResponderType, ScrollViewProps, @@ -105,6 +122,7 @@ export type { export {default as ScrollView} from './Libraries/Components/ScrollView/ScrollView'; export type { + SectionListInstance, SectionListProps, SectionListRenderItem, SectionListRenderItemInfo, @@ -114,6 +132,7 @@ export {default as SectionList} from './Libraries/Lists/SectionList'; export type { StatusBarAnimation, + StatusBarInstance, StatusBarProps, StatusBarStyle, } from './Libraries/Components/StatusBar/StatusBar'; @@ -121,11 +140,12 @@ export {default as StatusBar} from './Libraries/Components/StatusBar/StatusBar'; export type { SwitchChangeEvent, + SwitchInstance, SwitchProps, } from './Libraries/Components/Switch/Switch'; export {default as Switch} from './Libraries/Components/Switch/Switch'; -export type {TextProps} from './Libraries/Text/Text'; +export type {TextInstance, TextProps} from './Libraries/Text/Text'; export {default as Text} from './Libraries/Text/Text'; export type {NativeTextProps as unstable_NativeTextProps} from './Libraries/Text/TextNativeComponent'; export {NativeText as unstable_NativeText} from './Libraries/Text/TextNativeComponent'; @@ -138,6 +158,7 @@ export type { InputModeOptions, TextContentType, TextInputAndroidProps, + TextInputInstance, TextInputIOSProps, TextInputProps, TextInputChangeEvent, @@ -154,13 +175,22 @@ export {default as TextInput} from './Libraries/Components/TextInput/TextInput'; export {default as Touchable} from './Libraries/Components/Touchable/Touchable'; -export type {TouchableHighlightProps} from './Libraries/Components/Touchable/TouchableHighlight'; +export type { + TouchableHighlightInstance, + TouchableHighlightProps, +} from './Libraries/Components/Touchable/TouchableHighlight'; export {default as TouchableHighlight} from './Libraries/Components/Touchable/TouchableHighlight'; -export type {TouchableNativeFeedbackProps} from './Libraries/Components/Touchable/TouchableNativeFeedback'; +export type { + TouchableNativeFeedbackInstance, + TouchableNativeFeedbackProps, +} from './Libraries/Components/Touchable/TouchableNativeFeedback'; export {default as TouchableNativeFeedback} from './Libraries/Components/Touchable/TouchableNativeFeedback'; -export type {TouchableOpacityProps} from './Libraries/Components/Touchable/TouchableOpacity'; +export type { + TouchableOpacityInstance, + TouchableOpacityProps, +} from './Libraries/Components/Touchable/TouchableOpacity'; export {default as TouchableOpacity} from './Libraries/Components/Touchable/TouchableOpacity'; export type {TouchableWithoutFeedbackProps} from './Libraries/Components/Touchable/TouchableWithoutFeedback'; @@ -181,6 +211,7 @@ export type { ViewPropsAndroid, ViewPropsIOS, } from './Libraries/Components/View/ViewPropTypes'; +export type {ViewInstance} from './Libraries/Components/View/View'; export {default as View} from './Libraries/Components/View/View'; export {default as unstable_NativeView} from './Libraries/Components/View/ViewNativeComponent'; @@ -191,6 +222,7 @@ export type { Separators, VirtualizedListProps, } from './Libraries/Lists/VirtualizedList'; +export type {VirtualizedListInstance} from './Libraries/Lists/VirtualizedList'; export {default as VirtualizedList} from './Libraries/Lists/VirtualizedList'; export type { @@ -198,6 +230,7 @@ export type { SectionBase, VirtualizedSectionListProps, } from './Libraries/Lists/VirtualizedSectionList'; +export type {VirtualizedSectionListInstance} from './Libraries/Lists/VirtualizedSectionList'; export {default as VirtualizedSectionList} from './Libraries/Lists/VirtualizedSectionList'; // #endregion From 2bd18689778ebd1aeb951a5a03abd9294dd2c343 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Sat, 23 May 2026 06:44:06 -0700 Subject: [PATCH 2/2] Align to canonical *Instance types in component ref annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Update all ref parameters, ref-returning props, and `useRef` calls in built-in components to use the canonical `*Instance` types introduced in the previous diff. #### Changes - Replace inline `React.ElementRef` patterns with the canonical `*Instance` type in each component declaration and its inline destructuring type. - Replace `useRef>` with `useRef<*Instance>` (Pressable, Switch). - Replace `hostRef` prop types with the component `*Instance` type (TouchableHighlight, TouchableOpacity). - Update `ModalBaseProps.modalRef` and `ModalRefProps.ref` from deprecated `PublicModalInstance` to `ModalInstance`. #### Removed aliases - `ButtonRef` (Button.js) — inlined into `ButtonInstance` - `SwitchRef` (Switch.js) — replaced by `SwitchInstance` - `TextForwardRef` (Text.js) — replaced by `TextInstance` - `type Instance` (Pressable.js) — replaced by `PressableInstance` - `HostComponent` import (ActivityIndicator.js) — no longer needed - `ProgressBarAndroidNativeComponentType` typeof import (ProgressBarAndroid.js) — no longer needed Changelog: [Internal] Differential Revision: D106144380 --- .../ActivityIndicator/ActivityIndicator.js | 3 +- .../Libraries/Components/Button.js | 14 +- .../Components/Pressable/Pressable.js | 8 +- .../ProgressBarAndroid.android.js | 8 +- .../ProgressBarAndroid/ProgressBarAndroid.js | 5 +- .../Components/SafeAreaView/SafeAreaView.js | 2 +- .../Libraries/Components/Switch/Switch.js | 12 +- .../Touchable/TouchableHighlight.js | 6 +- .../Components/Touchable/TouchableOpacity.js | 6 +- .../Libraries/Components/View/View.js | 5 +- .../Libraries/Image/Image.android.js | 2 +- .../react-native/Libraries/Image/Image.ios.js | 2 +- .../react-native/Libraries/Modal/Modal.js | 4 +- packages/react-native/Libraries/Text/Text.js | 12 +- packages/react-native/ReactNativeApi.d.ts | 203 ++++++------------ 15 files changed, 95 insertions(+), 197 deletions(-) diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index d2d079c1891d..6337626a149d 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -9,7 +9,6 @@ */ 'use strict'; -import type {HostComponent} from '../../../src/private/types/HostComponent'; import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from '../View/ViewPropTypes'; @@ -65,7 +64,7 @@ export type ActivityIndicatorProps = Readonly<{ }>; const ActivityIndicator: component( - ref?: React.RefSetter>, + ref?: React.RefSetter, ...props: ActivityIndicatorProps ) = ({ ref: forwardedRef, diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index f8aa7ea3e891..8ed215d6a6cb 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -284,14 +284,18 @@ const NativeTouchable: | typeof TouchableOpacity = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity; -type ButtonRef = React.ElementRef; - -export type ButtonInstance = ButtonRef; +export type ButtonInstance = React.ElementRef; const Button: component( - ref?: React.RefSetter, + ref?: React.RefSetter, ...props: ButtonProps -) = ({ref, ...props}: {ref?: React.RefSetter, ...ButtonProps}) => { +) = ({ + ref, + ...props +}: { + ref?: React.RefSetter, + ...ButtonProps, +}) => { const { accessibilityLabel, accessibilityState, diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index bb631c321c2a..03cafea9e6a4 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -168,8 +168,6 @@ export type PressableProps = Readonly<{ ...PressableBaseProps, }>; -type Instance = React.ElementRef; - /** * Component used to build display components that should respond to whether the * component is currently pressed or not. @@ -178,7 +176,7 @@ function Pressable({ ref: forwardedRef, ...props }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...PressableProps, }): React.Node { const { @@ -218,7 +216,7 @@ function Pressable({ ...restProps } = props; - const viewRef = useRef(null); + const viewRef = useRef(null); const mergedRef = useMergeRefs(forwardedRef, viewRef); const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef); @@ -357,6 +355,6 @@ const MemoedPressable = memo(Pressable); MemoedPressable.displayName = 'Pressable'; export default MemoedPressable as component( - ref?: React.RefSetter>, + ref?: React.RefSetter, ...props: PressableProps ); diff --git a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js index 3c5f0e68e98a..3b68aa36fd1a 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -43,9 +43,7 @@ export type {ProgressBarAndroidProps}; * ``` */ const ProgressBarAndroid: component( - ref?: React.RefSetter< - React.ElementRef, - >, + ref?: React.RefSetter, ...props: ProgressBarAndroidProps ) = function ProgressBarAndroid({ ref: forwardedRef, @@ -55,9 +53,7 @@ const ProgressBarAndroid: component( animating = true, ...restProps }: { - ref?: React.RefSetter< - React.ElementRef, - >, + ref?: React.RefSetter, ...ProgressBarAndroidProps, }) { return ( diff --git a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js index 9a509e467862..1a6bd48ab1b5 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js @@ -11,7 +11,6 @@ 'use strict'; import type {HostInstance} from '../../../src/private/types/HostInstance'; -import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent'; import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes'; import Platform from '../../Utilities/Platform'; @@ -33,9 +32,7 @@ type Omit = T extends any ? Pick> : T; * @deprecated */ let ProgressBarAndroid: component( - ref?: React.RefSetter< - React.ElementRef, - >, + ref?: React.RefSetter, ...props: Omit ); diff --git a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js index 1dd49d3afd88..954a17825faf 100644 --- a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -28,7 +28,7 @@ import * as React from 'react'; * @deprecated Use `react-native-safe-area-context` instead. This component will be removed in a future release. */ const SafeAreaView: component( - ref?: React.RefSetter>, + ref?: React.RefSetter, ...props: ViewProps ) = Platform.select({ ios: require('./RCTSafeAreaViewNativeComponent').default, diff --git a/packages/react-native/Libraries/Components/Switch/Switch.js b/packages/react-native/Libraries/Components/Switch/Switch.js index 767d5e592270..96b481f53838 100644 --- a/packages/react-native/Libraries/Components/Switch/Switch.js +++ b/packages/react-native/Libraries/Components/Switch/Switch.js @@ -122,10 +122,6 @@ export type SwitchProps = Readonly<{ const returnsFalse = () => false; const returnsTrue = () => true; -type SwitchRef = React.ElementRef< - typeof SwitchNativeComponent | typeof AndroidSwitchNativeComponent, ->; - /** Renders a boolean input. @@ -168,13 +164,13 @@ type SwitchRef = React.ElementRef< ``` */ const Switch: component( - ref?: React.RefSetter, + ref?: React.RefSetter, ...props: SwitchProps ) = function Switch({ ref: forwardedRef, ...props }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...SwitchProps, }): React.Node { const { @@ -191,9 +187,7 @@ const Switch: component( const trackColorForFalse = trackColor?.false; const trackColorForTrue = trackColor?.true; - const nativeSwitchRef = useRef | null>(null); + const nativeSwitchRef = useRef(null); const ref = useMergeRefs(nativeSwitchRef, forwardedRef); diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js index ecd6f63204ba..940e2ad29dff 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js @@ -63,7 +63,7 @@ type TouchableHighlightBaseProps = Readonly<{ onHideUnderlay?: ?() => void, testOnly_pressed?: ?boolean, - hostRef?: React.RefSetter>, + hostRef?: React.RefSetter, }>; /** @build-types emit-as-interface Uniwind compatibility */ @@ -415,13 +415,13 @@ class TouchableHighlightImpl extends React.Component< } const TouchableHighlight: component( - ref?: React.RefSetter>, + ref?: React.RefSetter, ...props: Readonly> ) = ({ ref: hostRef, ...props }: { - ref?: React.RefSetter>, + ref?: React.RefSetter, ...Readonly>, }) => ; diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js index 852603410cb0..9ab92189708b 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js @@ -77,7 +77,7 @@ type TouchableOpacityBaseProps = Readonly<{ activeOpacity?: ?number, style?: ?Animated.WithAnimatedValue, - hostRef?: ?React.RefSetter>, + hostRef?: ?React.RefSetter, }>; export type TouchableOpacityProps = Readonly<{ @@ -381,13 +381,13 @@ class TouchableOpacity extends React.Component< } const Touchable: component( - ref?: React.RefSetter>, + ref?: React.RefSetter, ...props: TouchableOpacityProps ) = ({ ref, ...props }: { - ref?: React.RefSetter>, + ref?: React.RefSetter, ...TouchableOpacityProps, }) => ; diff --git a/packages/react-native/Libraries/Components/View/View.js b/packages/react-native/Libraries/Components/View/View.js index 9bc8acab1e90..b2e1f84cf731 100644 --- a/packages/react-native/Libraries/Components/View/View.js +++ b/packages/react-native/Libraries/Components/View/View.js @@ -25,10 +25,7 @@ import {use} from 'react'; * * @see https://reactnative.dev/docs/view */ -component View( - ref?: React.RefSetter>, - ...props: ViewProps -) { +component View(ref?: React.RefSetter, ...props: ViewProps) { const hasTextAncestor = use(TextAncestorContext); const { diff --git a/packages/react-native/Libraries/Image/Image.android.js b/packages/react-native/Libraries/Image/Image.android.js index da729075676f..fa04641aa978 100644 --- a/packages/react-native/Libraries/Image/Image.android.js +++ b/packages/react-native/Libraries/Image/Image.android.js @@ -169,7 +169,7 @@ let BaseImage: AbstractImageAndroid = ({ resizeMode, ...restProps }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...ImageProps, }) => { let source_ = diff --git a/packages/react-native/Libraries/Image/Image.ios.js b/packages/react-native/Libraries/Image/Image.ios.js index 6a41f4dccd5c..316457a04a70 100644 --- a/packages/react-native/Libraries/Image/Image.ios.js +++ b/packages/react-native/Libraries/Image/Image.ios.js @@ -113,7 +113,7 @@ let BaseImage: AbstractImageIOS = ({ ref: forwardedRef, ...props }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...ImageProps, }) => { const source = getImageSourcesFromImageProps(props) || { diff --git a/packages/react-native/Libraries/Modal/Modal.js b/packages/react-native/Libraries/Modal/Modal.js index a4ac0e387c4e..c689e10fb43c 100644 --- a/packages/react-native/Libraries/Modal/Modal.js +++ b/packages/react-native/Libraries/Modal/Modal.js @@ -111,7 +111,7 @@ export type ModalBaseProps = { /** * A ref to the native Modal component. */ - modalRef?: React.RefSetter, + modalRef?: React.RefSetter, }; export type ModalPropsIOS = { @@ -393,7 +393,7 @@ const styles = StyleSheet.create({ }); type ModalRefProps = Readonly<{ - ref?: React.RefSetter, + ref?: React.RefSetter, }>; // NOTE: This wrapper component is necessary because `Modal` is a class diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index 204b231f4a17..81a87c59b1c7 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -35,17 +35,13 @@ import {useContext, useMemo, useState} from 'react'; export type {TextProps} from './TextProps'; -type TextForwardRef = React.ElementRef< - typeof NativeText | typeof NativeVirtualText | typeof NativeSelectableText, ->; - /** * Text is the fundamental component for displaying text. * * @see https://reactnative.dev/docs/text */ const TextImpl: component( - ref?: React.RefSetter, + ref?: React.RefSetter, ...props: TextProps ) = ({ ref: forwardedRef, @@ -85,7 +81,7 @@ const TextImpl: component( style, ...restProps }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...TextProps, }) => { const processedProps = restProps as { @@ -483,7 +479,7 @@ function useTextPressability({ * expensive pressability logic to be only initialized when needed. */ component PressableVirtualText( - ref?: React.RefSetter, + ref?: React.RefSetter, textProps: NativeTextProps, textPressabilityProps: TextPressabilityProps, ) { @@ -509,7 +505,7 @@ component PressableVirtualText( * expensive pressability logic to be only initialized when needed. */ component PressableText( - ref?: React.RefSetter, + ref?: React.RefSetter, selectable?: ?boolean, textProps: NativeTextProps, textPressabilityProps: TextPressabilityProps, diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index fb682da7fd11..095570ece913 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<8cd07ad2b65dfc9ceb50f2ed411095c7>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -22,7 +22,6 @@ /* eslint-disable redundant-undefined/redundant-undefined */ import * as React from "react" -declare const $$AndroidSwitchNativeComponent: NativeType declare const $$AnimatedFlatList: ( props: Omit>, "ref"> & { ref?: React.Ref> @@ -87,11 +86,8 @@ declare const $$index: { } declare const $$NativeDeviceInfo: typeof NativeDeviceInfo_default declare const $$NativeDialogManagerAndroid: null | Spec | undefined -declare const $$ProgressBarAndroidNativeComponent: HostComponent declare const $$ReactFabric: typeof ReactFabric_default declare const $$ScrollViewContext: typeof ScrollViewContext_default -declare const $$SwitchNativeComponent: ComponentType -declare const $$ViewNativeComponent: typeof ViewNativeComponent_default declare const absoluteFill: AbsoluteFillStyle declare const AccessibilityInfo: typeof AccessibilityInfo_default declare const AccessibilityInfo_default: { @@ -142,7 +138,7 @@ declare const ActionSheetIOS_default: { declare const ActivityIndicator: typeof ActivityIndicator_default declare const ActivityIndicator_default: ( props: ActivityIndicatorProps & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const add: typeof $$AnimatedImplementation.add @@ -162,7 +158,7 @@ declare const BackHandler_default: TBackHandler declare const Button: typeof Button_default declare const Button_default: ( props: ButtonProps & { - ref?: React.Ref + ref?: React.Ref }, ) => React.ReactNode declare const Clipboard: { @@ -316,12 +312,9 @@ declare const NativeModules: typeof NativeModules_default declare let NativeModules_default: { [moduleName: string]: any } -declare const NativeSelectableText: HostComponent -declare const NativeText: HostComponent declare const NativeTouchable: | typeof TouchableNativeFeedback | typeof TouchableOpacity -declare const NativeVirtualText: HostComponent declare const Networking: typeof RCTNetworking_default declare const PanResponder: typeof PanResponder_default declare const PanResponder_default: { @@ -345,7 +338,7 @@ declare const Presets: { } declare const Pressable: ( props: PressableProps & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const processColor: typeof processColor_default @@ -354,10 +347,10 @@ declare let ProgressBarAndroid_default: ( props: Omit_2< Omit_2, keyof { - ref?: React.Ref> + ref?: React.Ref } > & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const RCTNativeAppEventEmitter_default: typeof DeviceEventEmitter @@ -394,7 +387,7 @@ declare const RootTagContext: React.Context declare const SafeAreaView: typeof SafeAreaView_default declare const SafeAreaView_default: ( props: ViewProps & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const ScrollView: typeof ScrollViewWrapper & ScrollViewComponentStatics @@ -450,13 +443,13 @@ declare const subtractImpl: ( declare const Switch: typeof Switch_default declare const Switch_default: ( props: SwitchProps & { - ref?: React.Ref + ref?: React.Ref }, ) => React.ReactNode declare const Text: typeof TextImpl_default declare const TextImpl_default: ( props: TextProps & { - ref?: React.Ref + ref?: React.Ref }, ) => React.ReactNode declare const TextInput: TextInputType @@ -488,13 +481,13 @@ declare const ToastAndroid_default: { declare const Touchable: typeof TouchableImpl_default declare const Touchable_default: ( props: TouchableOpacityProps & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const TouchableHighlight: typeof TouchableHighlight_default declare const TouchableHighlight_default: ( props: Readonly> & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const TouchableImpl_default: { @@ -552,7 +545,6 @@ declare const Vibration_default: { vibrate: (pattern?: Array | number, repeat?: boolean) => void } declare const View: typeof View_default -declare const ViewNativeComponent_default: HostComponent declare const VirtualizedList: typeof VirtualizedListComponent_default declare const VirtualizedListComponent_default: VirtualizedListType declare const VirtualizedListContext: React.Context @@ -997,8 +989,6 @@ declare class _TextInputInstance extends ReactNativeElement_default { isFocused(): boolean setSelection(start: number, end: number): void } -declare type $$AndroidSwitchNativeComponent = - typeof $$AndroidSwitchNativeComponent declare type $$AnimatedFlatList = typeof $$AnimatedFlatList declare type $$AnimatedImage = typeof $$AnimatedImage declare type $$AnimatedImplementation = typeof $$AnimatedImplementation @@ -1010,12 +1000,8 @@ declare type $$flattenStyle = typeof $$flattenStyle declare type $$index = typeof $$index declare type $$NativeDeviceInfo = typeof $$NativeDeviceInfo declare type $$NativeDialogManagerAndroid = typeof $$NativeDialogManagerAndroid -declare type $$ProgressBarAndroidNativeComponent = - typeof $$ProgressBarAndroidNativeComponent declare type $$ReactFabric = typeof $$ReactFabric declare type $$ScrollViewContext = typeof $$ScrollViewContext -declare type $$SwitchNativeComponent = typeof $$SwitchNativeComponent -declare type $$ViewNativeComponent = typeof $$ViewNativeComponent declare type absoluteFill = typeof absoluteFill declare type AbsoluteFillStyle = { readonly bottom: 0 @@ -1300,17 +1286,6 @@ declare type AndroidPlatform = { get isVision(): boolean get Version(): number } -declare type AndroidProgressBarNativeProps = Readonly< - Omit & { - animating?: WithDefault - color?: ColorValue - indeterminate: boolean - progress?: WithDefault - styleAttr?: string - testID?: WithDefault - typeAttr?: string - } -> declare type AndroidProps = { readonly nextFocusDown?: number readonly nextFocusForward?: number @@ -1318,24 +1293,6 @@ declare type AndroidProps = { readonly nextFocusRight?: number readonly nextFocusUp?: number } -declare type AndroidSwitchChangeEvent = { - readonly target: Int32 - readonly value: boolean -} -declare type AndroidSwitchNativeProps = Readonly< - ViewProps & { - disabled?: WithDefault - enabled?: WithDefault - on?: WithDefault - onChange?: BubblingEventHandler - thumbColor?: ColorValue - thumbTintColor?: ColorValue - trackColorForFalse?: ColorValue - trackColorForTrue?: ColorValue - trackTintColor?: ColorValue - value?: WithDefault - } -> declare namespace Animated { export { CompositeAnimation, @@ -1761,7 +1718,7 @@ declare type Builtin = ( ...$$REST$$: ReadonlyArray ) => Date | Error | RegExp | unknown declare type Button = typeof Button -declare type ButtonInstance = ButtonRef +declare type ButtonInstance = React.ComponentRef declare interface ButtonProps { readonly accessibilityActions?: ReadonlyArray readonly accessibilityHint?: string @@ -1794,7 +1751,6 @@ declare interface ButtonProps { readonly touchSoundDisabled?: boolean readonly onPress?: (event?: GestureResponderEvent) => unknown } -declare type ButtonRef = React.ComponentRef declare function cancelHeadlessTask(taskId: number, taskKey: string): void declare type Category = string declare type CellMetricProps = { @@ -1864,7 +1820,6 @@ declare type ComponentProviderInstrumentationHook = ( component_: ComponentProvider, scopedPerformanceLogger: IPerformanceLogger, ) => React.ComponentType -declare type ComponentType = HostComponent declare type compose = typeof compose declare function composeStyles_default( style1: null | U | undefined, @@ -3177,7 +3132,7 @@ declare interface ModalBaseProps { animated?: boolean animationType?: "fade" | "none" | "slide" backdropColor?: ColorValue - modalRef?: React.Ref + modalRef?: React.Ref onRequestClose?: DirectEventHandler onShow?: DirectEventHandler transparent?: boolean @@ -3211,7 +3166,7 @@ declare type ModalPropsIOS = { > } declare type ModalRefProps = { - readonly ref?: React.Ref + readonly ref?: React.Ref } declare type ModeChangeEvent = Readonly< Omit & { @@ -3376,11 +3331,6 @@ declare type NativeScrollVelocity = { readonly x: number readonly y: number } -declare type NativeSelectableText = typeof NativeSelectableText -declare type NativeSwitchChangeEvent = { - readonly target: Int32 - readonly value: boolean -} declare type NativeSyntheticEvent = { readonly bubbles: boolean | undefined readonly cancelable: boolean | undefined @@ -3401,15 +3351,6 @@ declare type NativeSyntheticEvent = { readonly preventDefault: () => void readonly stopPropagation: () => void } -declare type NativeText = typeof NativeText -declare type NativeTextProps = Readonly< - Omit & { - isHighlighted?: boolean - isPressable?: boolean - onClick?: (event: GestureResponderEvent) => unknown - selectionColor?: ProcessedColorValue - } -> declare type NativeTouchEvent = { readonly changedTouches: ReadonlyArray readonly force?: number @@ -3422,11 +3363,9 @@ declare type NativeTouchEvent = { readonly timestamp: number readonly touches: ReadonlyArray } -declare type NativeType = HostComponent declare interface NativeUIEvent { readonly detail: number } -declare type NativeVirtualText = typeof NativeVirtualText declare type Networking = typeof Networking declare type Node = symbol & { __Node__: string @@ -3873,8 +3812,6 @@ declare type ProgressBarAndroidBaseProps = { readonly testID?: string } declare type ProgressBarAndroidInstance = HostInstance -declare type ProgressBarAndroidNativeComponentType = - typeof $$ProgressBarAndroidNativeComponent declare type ProgressBarAndroidProps = | Readonly< ViewProps & @@ -3890,7 +3827,6 @@ declare type PromiseTask = { name: string gen: () => Promise } -declare type PublicModalInstance = ModalInstance declare type PublicRootInstance = symbol & { __PublicRootInstance__: string } @@ -5015,19 +4951,6 @@ declare type SwitchChangeEventData = { readonly value: boolean } declare type SwitchInstance = HostInstance -declare type SwitchNativeProps = Readonly< - ViewProps & { - disabled?: WithDefault - onChange?: BubblingEventHandler - onTintColor?: ColorValue - thumbColor?: ColorValue - thumbTintColor?: ColorValue - tintColor?: ColorValue - trackColorForFalse?: ColorValue - trackColorForTrue?: ColorValue - value?: WithDefault - } -> declare interface SwitchProps extends Readonly {} declare type SwitchPropsBase = { @@ -5047,9 +4970,6 @@ declare type SwitchPropsIOS = { thumbTintColor?: ColorValue tintColor?: ColorValue } -declare type SwitchRef = React.ComponentRef< - typeof $$AndroidSwitchNativeComponent | typeof $$SwitchNativeComponent -> declare namespace Systrace { export { isEnabled, @@ -5160,9 +5080,6 @@ declare type TextContentType = | "telephoneNumber" | "URL" | "username" -declare type TextForwardRef = React.ComponentRef< - typeof NativeSelectableText | typeof NativeText | typeof NativeVirtualText -> declare type TextInput = typeof TextInput declare type TextInputAndroidProps = { readonly cursorColor?: ColorValue @@ -5486,7 +5403,7 @@ declare type Touchable = typeof Touchable declare type TouchableHighlight = typeof TouchableHighlight declare type TouchableHighlightBaseProps = { readonly activeOpacity?: number - readonly hostRef?: React.Ref> + readonly hostRef?: React.Ref readonly onHideUnderlay?: () => void readonly onShowUnderlay?: () => void readonly style?: ViewStyleProp @@ -5572,7 +5489,7 @@ declare type TouchableNativeFeedbackTVProps = { declare type TouchableOpacity = typeof TouchableOpacity declare type TouchableOpacityBaseProps = { readonly activeOpacity?: number - readonly hostRef?: React.Ref> + readonly hostRef?: React.Ref readonly style?: Animated.WithAnimatedValue } declare type TouchableOpacityInstance = HostInstance @@ -5718,7 +5635,7 @@ declare type Vibration = typeof Vibration declare type View = typeof View declare function View_default( props: ViewProps & { - ref?: React.Ref> + ref?: React.Ref }, ): React.ReactNode declare type ViewabilityConfig = { @@ -6022,7 +5939,7 @@ export { AccessibilityValue, // cf8bcb74 ActionSheetIOS, // b558559e ActionSheetIOSOptions, // 1756eb5a - ActivityIndicator, // f06b0687 + ActivityIndicator, // b5073a60 ActivityIndicatorInstance, // 6ac360b7 ActivityIndicatorProps, // 5e976856 Alert, // 5bf12165 @@ -6031,9 +5948,9 @@ export { AlertOptions, // a0cdac0f AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // dac556c2 - AppConfig, // ce4209a7 - AppRegistry, // 5edf0524 + Animated, // b79d695c + AppConfig, // 35c0ca70 + AppRegistry, // ce465c83 AppState, // 12012be5 AppStateEvent, // 80f034c3 AppStateStatus, // 447e5ef2 @@ -6043,15 +5960,15 @@ export { BackPressEventName, // 4620fb76 BlurEvent, // e6151a1f BoxShadowValue, // b679703f - Button, // 869e5a89 - ButtonInstance, // c02f61d2 + Button, // 7ce12b33 + ButtonInstance, // 6c8b4aed ButtonProps, // 349967e6 Clipboard, // 41addb89 CodegenTypes, // 0b8108a8 ColorSchemeName, // 6615edd6 ColorValue, // 98989a8f - ComponentProvider, // b5c60ddd - ComponentProviderInstrumentationHook, // 9f640048 + ComponentProvider, // bf78f91b + ComponentProviderInstrumentationHook, // 68823a13 CursorValue, // 26522595 DevMenu, // 21b8b7a9 DevSettings, // e55b91dc @@ -6080,9 +5997,9 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // f29e5bae - FlatListInstance, // d705d4fe - FlatListProps, // 9ac3710e + FlatList, // 992ac191 + FlatListInstance, // d1c7989d + FlatListProps, // 6efc8b40 FocusEvent, // 62fc1eb8 FontVariant, // 7c7558bb GestureResponderEvent, // f693e9a5 @@ -6113,7 +6030,7 @@ export { ImageSourcePropType, // bfb5e5c6 ImageStyle, // ad6a6dee ImageURISource, // 016eb083 - InputAccessoryView, // d664987a + InputAccessoryView, // 0b924b84 InputAccessoryViewProps, // ac36060b InputModeOptions, // 4e8581b9 Insets, // e7fe432a @@ -6122,8 +6039,8 @@ export { KeyEvent, // 20fa4267 KeyUpEvent, // bc6bd87b Keyboard, // 49414c97 - KeyboardAvoidingView, // c8c29c8d - KeyboardAvoidingViewInstance, // 63a460fc + KeyboardAvoidingView, // ffbce540 + KeyboardAvoidingViewInstance, // 6b3e0f6f KeyboardAvoidingViewProps, // 4114f649 KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 @@ -6149,17 +6066,17 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // 37f44aff - ModalBaseProps, // 17e2ed28 + Modal, // 1de698b0 + ModalBaseProps, // 1a8a5daa ModalInstance, // fbd32990 - ModalProps, // 32ff7e1c + ModalProps, // ed53d13f ModalPropsAndroid, // 515fb173 ModalPropsIOS, // 144bbc95 ModeChangeEvent, // a5e9864f MouseEvent, // fdce82bc NativeAppEventEmitter, // 08d4c47d NativeColorValue, // d2094c29 - NativeComponentRegistry, // 21481a60 + NativeComponentRegistry, // 898bd939 NativeDialogManagerAndroid, // 5be8497e NativeEventEmitter, // 27f97c1a NativeEventSubscription, // de3942e7 @@ -6190,13 +6107,13 @@ export { PointerEvent, // fe3989a1 PressabilityConfig, // 6dedcb61 PressabilityEventHandlers, // 3e6c0f56 - Pressable, // 0241ba70 + Pressable, // b7db0f5b PressableAndroidRippleConfig, // ee32eaca PressableInstance, // c93aef84 PressableProps, // a9048420 PressableStateCallbackType, // 9af36561 ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // 00fcd180 + ProgressBarAndroid, // 27c901d1 ProgressBarAndroidInstance, // de8a2c3a ProgressBarAndroidProps, // f59f8f03 PromiseTask, // 5102c862 @@ -6221,26 +6138,26 @@ export { RootViewStyleProvider, // d4818465 Runnable, // 594dd93a Runnables, // 4367c557 - SafeAreaView, // a7cd92bb + SafeAreaView, // 90fc428c SafeAreaViewInstance, // a9027869 ScaledSize, // 07e417c7 ScrollEvent, // 5d529218 - ScrollResponderType, // 190f136e + ScrollResponderType, // 6745d866 ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // ba50902e - ScrollViewImperativeMethods, // ea8c81c5 - ScrollViewInstance, // e9ff1b20 - ScrollViewProps, // 038eaec5 + ScrollView, // c241f568 + ScrollViewImperativeMethods, // 3cb35fb7 + ScrollViewInstance, // f5b02697 + ScrollViewProps, // d2fb4240 ScrollViewPropsAndroid, // 44210553 ScrollViewPropsIOS, // b34b696c ScrollViewScrollToOptions, // 3313411e - SectionBase, // b376bddc - SectionList, // 2a3caa23 - SectionListData, // 119baf83 - SectionListInstance, // eb3accfa - SectionListProps, // 0c74fddf - SectionListRenderItem, // 1fad0435 - SectionListRenderItemInfo, // 745e1992 + SectionBase, // dca83594 + SectionList, // bffe9d39 + SectionListData, // e0d79987 + SectionListInstance, // 5e01bac3 + SectionListProps, // 157d9737 + SectionListRenderItem, // 466e3e87 + SectionListRenderItemInfo, // d809238e Separators, // 6a45f7e3 Settings, // 2be0c61e Share, // e4591b32 @@ -6258,7 +6175,7 @@ export { StyleProp, // fa0e9b4a StyleSheet, // e77dd046 SubmitBehavior, // c4ddf490 - Switch, // 015be3f7 + Switch, // 6a13e7f9 SwitchChangeEvent, // 63e9c50b SwitchInstance, // 9fddadca SwitchProps, // 0dbf23ea @@ -6266,7 +6183,7 @@ export { TVViewPropsIOS, // 330ce7b5 TargetedEvent, // 16e98910 TaskProvider, // 266dedf2 - Text, // 608149e8 + Text, // c9bd85e7 TextContentType, // 239b3ecc TextInput, // b541a946 TextInputAndroidProps, // 3f09ce49 @@ -6286,15 +6203,15 @@ export { TextStyle, // bb9b7a58 ToastAndroid, // 88a8969a Touchable, // da3239ee - TouchableHighlight, // 49bbefe7 + TouchableHighlight, // f8c3ef97 TouchableHighlightInstance, // 96d47f78 - TouchableHighlightProps, // f14a1131 + TouchableHighlightProps, // 692ae24e TouchableNativeFeedback, // d89b59a8 TouchableNativeFeedbackInstance, // beb58e1e TouchableNativeFeedbackProps, // a88ade2e - TouchableOpacity, // 8d1b023b + TouchableOpacity, // d16c67c4 TouchableOpacityInstance, // 09bc64ed - TouchableOpacityProps, // 908e84b9 + TouchableOpacityProps, // 3ba596f7 TouchableWithoutFeedback, // 71d446ec TouchableWithoutFeedbackProps, // e0c1c566 TransformsStyle, // 65e70f18 @@ -6303,7 +6220,7 @@ export { UIManager, // a1a7cc01 UTFSequence, // ad625158 Vibration, // 31e4bbf8 - View, // 234d8db5 + View, // 803b8545 ViewInstance, // 1a59bec1 ViewProps, // 6d644e8b ViewPropsAndroid, // ac650c5c @@ -6312,11 +6229,11 @@ export { VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e VirtualizedListInstance, // 423ee7c0 - VirtualizedListProps, // a9901686 + VirtualizedListProps, // 055bf5f2 VirtualizedSectionList, // 9fd9cd61 VirtualizedSectionListInstance, // 12b706d5 - VirtualizedSectionListProps, // 90e14aed - WrapperComponentProvider, // 9cf3844c + VirtualizedSectionListProps, // 089fae78 + WrapperComponentProvider, // 4b8c7962 codegenNativeCommands, // 628a7c0a codegenNativeComponent, // 2baac257 findNodeHandle, // 93f80214