diff --git a/packages/eslint-plugin-react-native/utils.js b/packages/eslint-plugin-react-native/utils.js index 01c41d361b64..98d1e90ca0b0 100644 --- a/packages/eslint-plugin-react-native/utils.js +++ b/packages/eslint-plugin-react-native/utils.js @@ -327,10 +327,6 @@ const publicAPIMapping = { default: 'LogBox', types: ['ExtendedExceptionData', 'IgnorePattern', 'LogData'], }, - 'Libraries/NativeModules/specs/NativeDialogManagerAndroid': { - default: 'NativeDialogManagerAndroid', - types: null, - }, 'Libraries/EventEmitter/NativeEventEmitter': { default: 'NativeEventEmitter', types: [ diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 28bc1886ee00..63bddf2e9504 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -9,7 +9,7 @@ */ 'use strict'; -import type {HostComponent} from '../../../src/private/types/HostComponent'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from '../View/ViewPropTypes'; import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet'; @@ -17,6 +17,8 @@ import Platform from '../../Utilities/Platform'; import View from '../View/View'; import * as React from 'react'; +export type ActivityIndicatorInstance = HostInstance; + const PlatformActivityIndicator = Platform.OS === 'android' ? require('../ProgressBarAndroid/ProgressBarAndroid').default @@ -62,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 40a926d8ac15..8ed215d6a6cb 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -284,12 +284,18 @@ const NativeTouchable: | typeof TouchableOpacity = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity; -type ButtonRef = React.ElementRef; +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/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..78d32ecbf5f1 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, @@ -27,6 +28,8 @@ import useAndroidRippleForView, { import * as React from 'react'; import {memo, useMemo, useRef, useState} from 'react'; +export type PressableInstance = HostInstance; + export type {PressableAndroidRippleConfig}; export type PressableStateCallbackType = Readonly<{ @@ -165,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. @@ -175,7 +176,7 @@ function Pressable({ ref: forwardedRef, ...props }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...PressableProps, }): React.Node { const { @@ -215,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); @@ -354,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 aadcb2aee3ec..f4bde323e46f 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js @@ -8,12 +8,15 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ProgressBarAndroidProps} from './ProgressBarAndroidTypes'; import ProgressBarAndroidNativeComponent from './ProgressBarAndroidNativeComponent'; const React = require('react'); +export type ProgressBarAndroidInstance = HostInstance; + export type {ProgressBarAndroidProps}; /** @@ -40,9 +43,7 @@ export type {ProgressBarAndroidProps}; * ``` */ const ProgressBarAndroid: component( - ref?: React.RefSetter< - React.ElementRef, - >, + ref?: React.RefSetter, ...props: ProgressBarAndroidProps ) = function ProgressBarAndroid({ ref: forwardedRef, @@ -52,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 447327cb6695..1a6bd48ab1b5 100644 --- a/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +++ b/packages/react-native/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js @@ -10,11 +10,13 @@ 'use strict'; -import typeof ProgressBarAndroidNativeComponentType from './ProgressBarAndroidNativeComponent'; +import type {HostInstance} from '../../../src/private/types/HostInstance'; 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 @@ -30,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/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..b6f5a47aaf75 100644 --- a/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js +++ b/packages/react-native/Libraries/Components/SafeAreaView/SafeAreaView.js @@ -8,12 +8,15 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from '../View/ViewPropTypes'; import Platform from '../../Utilities/Platform'; import View from '../View/View'; import * as React from 'react'; +export type SafeAreaViewInstance = HostInstance; + /** * Renders nested content and automatically applies paddings reflect the portion * of the view that is not covered by navigation bars, tab bars, toolbars, and @@ -25,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/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index d19eb049ee1f..fea4d853ceb3 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 { +getScrollableNode: () => ?number; +getInnerViewNode: () => ?number; +getInnerViewRef: () => InnerViewInstance | null; - +getNativeScrollRef: () => PublicScrollViewInstance | null; + +getNativeScrollRef: () => ScrollViewInstance | null; +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 5a391305b6b3..2145d12fbf54 100644 --- a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js +++ b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js @@ -561,4 +561,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..9ca1fc523f4e 100644 --- a/packages/react-native/Libraries/Components/Switch/Switch.js +++ b/packages/react-native/Libraries/Components/Switch/Switch.js @@ -8,6 +8,7 @@ * @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'; @@ -25,6 +26,8 @@ import SwitchNativeComponent, { import * as React from 'react'; import {useLayoutEffect, useRef, useState} from 'react'; +export type SwitchInstance = HostInstance; + export type SwitchPropsIOS = { /** * Background color when the switch is turned on. @@ -119,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. @@ -165,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 { @@ -188,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/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 0b6e00f21dc6..5fe029ae0be2 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableHighlight.js @@ -8,6 +8,7 @@ * @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'; @@ -23,6 +24,8 @@ import warnOnce from '../../Utilities/warnOnce'; import * as React from 'react'; import {cloneElement} from 'react'; +export type TouchableHighlightInstance = HostInstance; + type AndroidProps = Readonly<{ nextFocusDown?: ?number, nextFocusForward?: ?number, @@ -61,7 +64,7 @@ type TouchableHighlightBaseProps = Readonly<{ onHideUnderlay?: ?() => void, testOnly_pressed?: ?boolean, - hostRef?: React.RefSetter>, + hostRef?: React.RefSetter, }>; /** @build-types emit-as-interface Uniwind compatibility */ @@ -422,13 +425,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/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..1dfdb8393482 100644 --- a/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableOpacity.js @@ -8,6 +8,7 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewStyleProp} from '../../StyleSheet/StyleSheet'; import type {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback'; @@ -21,6 +22,8 @@ import flattenStyle from '../../StyleSheet/flattenStyle'; import Platform from '../../Utilities/Platform'; import * as React from 'react'; +export type TouchableOpacityInstance = HostInstance; + export type TouchableOpacityTVProps = Readonly<{ /** * *(Apple TV only)* TV preferred focus (see documentation for the View component). @@ -74,7 +77,7 @@ type TouchableOpacityBaseProps = Readonly<{ activeOpacity?: ?number, style?: ?Animated.WithAnimatedValue, - hostRef?: ?React.RefSetter>, + hostRef?: ?React.RefSetter, }>; export type TouchableOpacityProps = Readonly<{ @@ -378,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 c2486bde14a5..ca5495dd43c4 100644 --- a/packages/react-native/Libraries/Components/View/View.js +++ b/packages/react-native/Libraries/Components/View/View.js @@ -8,6 +8,7 @@ * @format */ +import type {HostInstance} from '../../../src/private/types/HostInstance'; import type {ViewProps} from './ViewPropTypes'; import TextAncestorContext from '../../Text/TextAncestorContext'; @@ -15,6 +16,8 @@ import ViewNativeComponent from './ViewNativeComponent'; import * as React from 'react'; import {use} from 'react'; +export type ViewInstance = HostInstance; + /** * The most fundamental component for building a UI, View is a container that * supports layout with flexbox, style, some touch handling, and accessibility @@ -22,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 4ca519311030..b20bdfa5f6fa 100644 --- a/packages/react-native/Libraries/Image/Image.android.js +++ b/packages/react-native/Libraries/Image/Image.android.js @@ -31,6 +31,8 @@ import resolveAssetSource from './resolveAssetSource'; import * as React from 'react'; import {use} from 'react'; +export type ImageInstance = HostInstance; + let _requestId = 1; function generateRequestId() { return _requestId++; @@ -167,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 0580736dac42..3fc14f2bcf14 100644 --- a/packages/react-native/Libraries/Image/Image.ios.js +++ b/packages/react-native/Libraries/Image/Image.ios.js @@ -30,6 +30,8 @@ import NativeImageLoaderIOS from './NativeImageLoaderIOS'; import resolveAssetSource from './resolveAssetSource'; import * as React from 'react'; +export type ImageInstance = HostInstance; + function getSize( uri: string, success?: (width: number, height: number) => void, @@ -111,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/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..13f1106f66d0 100644 --- a/packages/react-native/Libraries/Image/ImageTypes.flow.js +++ b/packages/react-native/Libraries/Image/ImageTypes.flow.js @@ -16,6 +16,8 @@ import type {ImageSource} from './ImageSource'; import * as React from 'react'; +export type ImageInstance = HostInstance; + export type ImageSize = { width: number, height: number, 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..c689e10fb43c 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 @@ -108,7 +111,7 @@ export type ModalBaseProps = { /** * A ref to the native Modal component. */ - modalRef?: React.RefSetter, + modalRef?: React.RefSetter, }; export type ModalPropsIOS = { @@ -390,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/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index 2d8c0e42d679..190d559a7117 100644 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -37,16 +37,6 @@ import typeof deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAnd import typeof deepDiffer from '../Utilities/differ/deepDiffer'; import typeof Platform from '../Utilities/Platform'; -// Expose these types to the React renderer -export type { - HostInstance as PublicInstance, - // These types are only necessary for Paper - NativeMethods as LegacyPublicInstance, - MeasureOnSuccessCallback, - MeasureInWindowOnSuccessCallback, - MeasureLayoutOnSuccessCallback, -} from '../../src/private/types/HostInstance'; - export type {PublicRootInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; export type PublicTextInstance = ReturnType; diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow index 501df15989b3..da6972e835df 100644 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +++ b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow @@ -10,16 +10,6 @@ import typeof {createPublicTextInstance as createPublicTextInstanceT} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; -export type { - HostInstance as PublicInstance, - - // These types are only necessary for Paper - NativeMethods as LegacyPublicInstance, - MeasureOnSuccessCallback, - MeasureInWindowOnSuccessCallback, - MeasureLayoutOnSuccessCallback, -} from '../../src/private/types/HostInstance'; - export type {PublicRootInstance} from '../ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance'; export type PublicTextInstance = ReturnType; diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index 8e7b29cb6096..8efa7be273fe 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -8,6 +8,7 @@ * @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'; @@ -30,11 +31,9 @@ import { import * as React from 'react'; import {useContext, useMemo, useState} from 'react'; -export type {TextProps} from './TextProps'; +export type TextInstance = HostInstance; -type TextForwardRef = React.ElementRef< - typeof NativeText | typeof NativeVirtualText | typeof NativeSelectableText, ->; +export type {TextProps} from './TextProps'; /** * Text is the fundamental component for displaying text. @@ -42,7 +41,7 @@ type TextForwardRef = React.ElementRef< * @see https://reactnative.dev/docs/text */ const TextImpl: component( - ref?: React.RefSetter, + ref?: React.RefSetter, ...props: TextProps ) = ({ ref: forwardedRef, @@ -82,7 +81,7 @@ const TextImpl: component( style, ...restProps }: { - ref?: React.RefSetter, + ref?: React.RefSetter, ...TextProps, }) => { const processedProps = restProps as { @@ -480,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, ) { @@ -506,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/Libraries/Text/TextProps.js b/packages/react-native/Libraries/Text/TextProps.js index d6be6a5658cb..52925d611077 100644 --- a/packages/react-native/Libraries/Text/TextProps.js +++ b/packages/react-native/Libraries/Text/TextProps.js @@ -124,6 +124,13 @@ export type TextPropsAndroid = { type TextBaseProps = Readonly<{ onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown, + /** + * Controls whether the `Text` can be the target of touch events. + * + * See https://reactnative.dev/docs/view#pointerevents + */ + pointerEvents?: ?('auto' | 'box-none' | 'box-only' | 'none'), + /** * Whether fonts should scale to respect Text Size accessibility settings. * The default is `true`. diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index a34c29584d98..a48cac5cc8a3 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<<88d962e8bf936576e85b897a4192f39a>> + * @generated SignedSource<<7ddeef0f06d1401a39aae96f403b7896>> * * 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> @@ -86,12 +85,8 @@ declare const $$index: { get VirtualizedSectionList(): AnyVirtualizedSectionList } 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 +137,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 +157,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: { @@ -287,17 +282,13 @@ declare const NativeAppEventEmitter: typeof RCTNativeAppEventEmitter_default declare const NativeDeviceInfo_default: { getConstants(): DeviceInfoConstants } -declare const NativeDialogManagerAndroid: typeof $$NativeDialogManagerAndroid 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: { @@ -321,7 +312,7 @@ declare const Presets: { } declare const Pressable: ( props: PressableProps & { - ref?: React.Ref> + ref?: React.Ref }, ) => React.ReactNode declare const processColor: typeof processColor_default @@ -330,10 +321,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 @@ -370,14 +361,14 @@ 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 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 @@ -426,13 +417,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 @@ -464,13 +455,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: { @@ -528,7 +519,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 @@ -973,8 +963,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 @@ -985,13 +973,8 @@ declare type $$AnimatedView = typeof $$AnimatedView 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 @@ -1178,6 +1161,7 @@ declare type ActiveCallback = ( gestureState: PanResponderGestureState, ) => boolean declare type ActivityIndicator = typeof ActivityIndicator +declare type ActivityIndicatorInstance = HostInstance declare type ActivityIndicatorIOSProps = { readonly hidesWhenStopped?: boolean } @@ -1275,17 +1259,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 @@ -1293,24 +1266,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, @@ -1736,6 +1691,7 @@ declare type Builtin = ( ...$$REST$$: ReadonlyArray ) => Date | Error | RegExp | unknown declare type Button = typeof Button +declare type ButtonInstance = React.ComponentRef declare interface ButtonProps { readonly accessibilityActions?: ReadonlyArray readonly accessibilityHint?: string @@ -1768,7 +1724,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 = { @@ -1838,7 +1793,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, @@ -1956,17 +1910,6 @@ declare type DevMenuStatic = { show(): void } declare type DevSettings = typeof DevSettings -declare type DialogAction = string -declare type DialogButtonKey = number -declare type DialogOptions = { - buttonNegative?: string - buttonNeutral?: string - buttonPositive?: string - cancelable?: boolean - items?: Array - message?: string - title?: string -} declare type diffClamp = typeof diffClamp declare class Dimensions { static addEventListener(type: "change", handler: Function): EventSubscription @@ -2073,6 +2016,7 @@ declare class DrawerLayoutAndroid_default render(): React.ReactNode setNativeProps(nativeProps: Object): void } +declare type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods declare interface DrawerLayoutAndroidMethods { blur(): void closeDrawer(): void @@ -2306,7 +2250,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 @@ -2336,6 +2280,7 @@ declare class FlatList extends React.PureComponent< } declare type FlatListBaseProps = RequiredFlatListProps & OptionalFlatListProps +declare type FlatListInstance = FlatList declare interface FlatListProps extends Readonly< Omit< @@ -2516,6 +2461,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 @@ -2566,6 +2512,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 = { @@ -2840,6 +2787,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 @@ -2972,18 +2920,6 @@ declare type LayoutRectangle = { readonly x: number readonly y: number } -declare interface LegacyHostInstanceMethods { - blur(): void - focus(): void - measure(callback: MeasureOnSuccessCallback): void - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void - measureLayout( - relativeToNativeNode: HostInstance | number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail?: () => void, - ): void - setNativeProps(nativeProps: {}): void -} declare type Linking = typeof Linking declare type LinkingEventDefinitions = { url: [ @@ -3140,12 +3076,13 @@ declare interface ModalBaseProps { animated?: boolean animationType?: "fade" | "none" | "slide" backdropColor?: ColorValue - modalRef?: React.Ref + modalRef?: React.Ref onRequestClose?: DirectEventHandler onShow?: DirectEventHandler transparent?: boolean visible?: boolean } +declare type ModalInstance = HostInstance declare type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid & @@ -3173,7 +3110,7 @@ declare type ModalPropsIOS = { > } declare type ModalRefProps = { - readonly ref?: React.Ref + readonly ref?: React.Ref } declare type ModeChangeEvent = Readonly< Omit & { @@ -3213,7 +3150,6 @@ declare namespace NativeComponentRegistry { export { setRuntimeConfigProvider, get, getWithFallback_DEPRECATED } } declare type NativeComponentType = HostComponent -declare type NativeDialogManagerAndroid = typeof NativeDialogManagerAndroid declare class NativeEventEmitter< TEventToArgsMap extends Readonly< Record> @@ -3256,8 +3192,6 @@ declare type NativeMeasureOnSuccessCallback = ( pageX: number, pageY: number, ) => void -declare type NativeMethods = LegacyHostInstanceMethods -declare type NativeMethodsMixin = LegacyHostInstanceMethods declare type NativeModeChangeEvent = { readonly mode: Int32 readonly targetRect: { @@ -3338,11 +3272,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 @@ -3363,15 +3292,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 @@ -3384,11 +3304,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 @@ -3808,6 +3726,7 @@ declare type PressableBaseProps = { readonly testID?: string readonly testOnly_pressed?: boolean } +declare type PressableInstance = HostInstance declare interface PressableProps extends Readonly< Omit & PressableBaseProps @@ -3833,8 +3752,7 @@ declare type ProgressBarAndroidBaseProps = { readonly color?: ColorValue readonly testID?: string } -declare type ProgressBarAndroidNativeComponentType = - typeof $$ProgressBarAndroidNativeComponent +declare type ProgressBarAndroidInstance = HostInstance declare type ProgressBarAndroidProps = | Readonly< ViewProps & @@ -3846,13 +3764,9 @@ declare type ProgressBarAndroidProps = ProgressBarAndroidBaseProps & IndeterminateProgressBarAndroidStyleAttrProp > -declare type PublicModalInstance = HostInstance declare type PublicRootInstance = symbol & { __PublicRootInstance__: string } -declare interface PublicScrollViewInstance - extends HostInstance, - ScrollViewImperativeMethods {} declare type PublicTextInstance = ReturnType declare interface PushNotification { finish(result: string): void @@ -4005,10 +3919,7 @@ declare class ReactNativeDocument_default extends ReadOnlyNode_default { declare type ReactNativeDocumentInstanceHandle = symbol & { __ReactNativeDocumentInstanceHandle__: string } -declare class ReactNativeElement_default - extends ReadOnlyElement_default - implements NativeMethods -{ +declare class ReactNativeElement_default extends ReadOnlyElement_default { blur(): void protected constructor() focus(): void @@ -4128,6 +4039,7 @@ declare type RefreshControlBaseProps = { readonly progressViewOffset?: number readonly refreshing: boolean } +declare type RefreshControlInstance = RefreshControl declare interface RefreshControlProps extends Readonly< ViewProps & @@ -4360,6 +4272,7 @@ declare type Runnables = { [appKey: string]: Runnable } declare type SafeAreaView = typeof SafeAreaView +declare type SafeAreaViewInstance = HostInstance declare type ScaledSize = DisplayMetrics declare type ScheduleLocalNotificationDetails = PresentLocalNotificationDetails & { @@ -4405,7 +4318,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 @@ -4431,7 +4344,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: ( @@ -4458,6 +4371,9 @@ declare interface ScrollViewImperativeMethods { options?: ScrollViewScrollToOptions | undefined, ) => void } +declare interface ScrollViewInstance + extends HostInstance, + ScrollViewImperativeMethods {} declare interface ScrollViewProps extends Readonly< ViewProps & @@ -4565,6 +4481,7 @@ declare type SectionListData< | (Readonly> & SectionT) | (SectionBase & SectionT) | SectionT +declare type SectionListInstance = SectionList declare interface SectionListProps extends Readonly< Omit< @@ -4671,20 +4588,6 @@ declare type ShareOptions = { tintColor?: ColorValue } declare interface Spec extends TurboModule { - readonly getConstants: () => { - readonly buttonClicked: DialogAction - readonly buttonNegative: DialogButtonKey - readonly buttonNeutral: DialogButtonKey - readonly buttonPositive: DialogButtonKey - readonly dismissed: DialogAction - } - readonly showAlert: ( - config: DialogOptions, - onError: (error: string) => void, - onAction: (action: DialogAction, buttonKey?: DialogButtonKey) => void, - ) => void -} -declare interface Spec_2 extends TurboModule { readonly blur?: (reactTag: number) => void readonly clearJSResponder: () => void readonly configureNextLayoutAnimation: ( @@ -4902,6 +4805,7 @@ declare type StatusBarBaseProps = { readonly barStyle?: "auto" | "dark-content" | "default" | "light-content" readonly hidden?: boolean } +declare type StatusBarInstance = StatusBar declare type StatusBarProps = Readonly< StatusBarPropsAndroid & StatusBarPropsIOS & StatusBarBaseProps > @@ -4952,19 +4856,7 @@ declare type SwitchChangeEventData = { readonly target: number readonly value: boolean } -declare type SwitchNativeProps = Readonly< - ViewProps & { - disabled?: WithDefault - onChange?: BubblingEventHandler - onTintColor?: ColorValue - thumbColor?: ColorValue - thumbTintColor?: ColorValue - tintColor?: ColorValue - trackColorForFalse?: ColorValue - trackColorForTrue?: ColorValue - value?: WithDefault - } -> +declare type SwitchInstance = HostInstance declare interface SwitchProps extends Readonly {} declare type SwitchPropsBase = { @@ -4984,9 +4876,6 @@ declare type SwitchPropsIOS = { thumbTintColor?: ColorValue tintColor?: ColorValue } -declare type SwitchRef = React.ComponentRef< - typeof $$AndroidSwitchNativeComponent | typeof $$SwitchNativeComponent -> declare namespace Systrace { export { isEnabled, @@ -5043,6 +4932,7 @@ declare type TextBaseProps = { readonly onResponderTerminationRequest?: () => boolean readonly onStartShouldSetResponder?: () => boolean readonly onTextLayout?: (event: TextLayoutEvent) => unknown + readonly pointerEvents?: "auto" | "box-none" | "box-only" | "none" readonly pressRetentionOffset?: PressRetentionOffset readonly role?: Role readonly selectable?: boolean @@ -5096,9 +4986,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 @@ -5337,6 +5224,7 @@ declare type TextInputSubmitEditingEventData = Readonly< } > declare type TextInputType = InternalTextInput & TextInputComponentStatics +declare type TextInstance = HostInstance declare type TextLayoutEvent = NativeSyntheticEvent declare type TextLayoutEventData = { readonly lines: Array @@ -5421,13 +5309,14 @@ 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 readonly testOnly_pressed?: boolean readonly underlayColor?: ColorValue } +declare type TouchableHighlightInstance = HostInstance declare interface TouchableHighlightProps extends Readonly< TouchableWithoutFeedbackProps & @@ -5471,6 +5360,7 @@ declare class TouchableNativeFeedback extends React.Component< componentWillUnmount(): void render(): React.ReactNode } +declare type TouchableNativeFeedbackInstance = TouchableNativeFeedback declare type TouchableNativeFeedbackProps = Readonly< TouchableWithoutFeedbackProps & TouchableNativeFeedbackTVProps & { @@ -5505,9 +5395,10 @@ 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 declare type TouchableOpacityProps = Readonly< TouchableWithoutFeedbackProps & TouchableOpacityTVProps & @@ -5599,7 +5490,7 @@ declare type TVViewPropsIOS = { readonly tvParallaxTiltAngle?: number } declare type UIManager = typeof UIManager -declare interface UIManagerJSInterface extends Spec_2 { +declare interface UIManagerJSInterface extends Spec { readonly getViewManagerConfig: (viewManagerName: string) => Object readonly hasViewManagerConfig: (viewManagerName: string) => boolean } @@ -5650,7 +5541,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 = { @@ -5745,6 +5636,7 @@ declare type ViewConfig = { readonly uiViewClassName: string readonly validAttributes: AttributeConfiguration } +declare type ViewInstance = HostInstance declare interface ViewProps extends Readonly< DirectEventProps & @@ -5830,12 +5722,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, @@ -5942,25 +5837,26 @@ declare type WrapperComponentProvider = ( appParameters: Object, ) => React.ComponentType export { - AccessibilityActionEvent, // 9ead30c4 - AccessibilityInfo, // f7cbfa51 + AccessibilityActionEvent, // a0d4daa0 + AccessibilityInfo, // 23a3aa9b AccessibilityProps, // 5a2836fc AccessibilityRole, // f2f2e066 AccessibilityState, // b0c2b3f7 AccessibilityValue, // cf8bcb74 ActionSheetIOS, // b558559e ActionSheetIOSOptions, // 1756eb5a - ActivityIndicator, // 7c0fa2e8 - ActivityIndicatorProps, // d3357183 + ActivityIndicator, // b2398ac8 + ActivityIndicatorInstance, // a82dd4e7 + ActivityIndicatorProps, // 410756e8 Alert, // 5bf12165 AlertButton, // bf1a3b60 AlertButtonStyle, // ec9fb242 AlertOptions, // a0cdac0f AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // d3264d4b - AppConfig, // ce4209a7 - AppRegistry, // 5edf0524 + Animated, // b7df8516 + AppConfig, // 35c0ca70 + AppRegistry, // ce465c83 AppState, // 12012be5 AppStateEvent, // 80f034c3 AppStateStatus, // 447e5ef2 @@ -5968,16 +5864,17 @@ export { AutoCapitalize, // c0e857a0 BackHandler, // f139fc69 BackPressEventName, // 4620fb76 - BlurEvent, // 4d39aa26 + BlurEvent, // 4ba4f941 BoxShadowValue, // b679703f - Button, // 2a455f1c - ButtonProps, // b276cb7a + Button, // 2763dfbf + ButtonInstance, // 93fc348a + ButtonProps, // 35ffc98c Clipboard, // 41addb89 - CodegenTypes, // 51ca21ff + CodegenTypes, // ab4986cc ColorSchemeName, // 6615edd6 ColorValue, // 98989a8f - ComponentProvider, // b5c60ddd - ComponentProviderInstrumentationHook, // 9f640048 + ComponentProvider, // bf78f91b + ComponentProviderInstrumentationHook, // 68823a13 CursorValue, // 26522595 DevMenu, // 21b8b7a9 DevSettings, // e55b91dc @@ -5989,9 +5886,10 @@ export { DimensionsPayload, // 653bc26c DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb - DrawerLayoutAndroid, // 3939f773 - DrawerLayoutAndroidProps, // ec039f19 - DrawerSlideEvent, // 6a679d9c + DrawerLayoutAndroid, // 4dcb4a45 + DrawerLayoutAndroidInstance, // c0694352 + DrawerLayoutAndroidProps, // 2f0e6568 + DrawerSlideEvent, // c4ab8fba DropShadowValue, // e9df2606 DynamicColorIOS, // d96c228c DynamicColorIOSTuple, // 023ce58e @@ -6005,28 +5903,31 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // fda604e6 - FlatListProps, // 4386b761 - FocusEvent, // 4fab86b8 + FlatList, // cb72efc9 + FlatListInstance, // 8ae5b7be + FlatListProps, // 51cbbb65 + FocusEvent, // 850f1517 FontVariant, // 7c7558bb - GestureResponderEvent, // 30249124 - GestureResponderHandlers, // 23b0d45f - HostComponent, // 277fe52e - HostInstance, // 3a2a75ad + GestureResponderEvent, // 14d3e77a + GestureResponderHandlers, // c976c2ea + HostComponent, // a611806a + HostInstance, // f78dcaf8 I18nManager, // f9870e00 IEventEmitter, // fbef6131 IOSKeyboardEvent, // e67bfe3a IgnorePattern, // ec6f6ece - Image, // 10e30790 - ImageBackground, // ab05f7c3 - ImageBackgroundProps, // a35908a1 - ImageErrorEvent, // 3c2e70cc - ImageLoadEvent, // 6d3e7731 - ImageProgressEventIOS, // fb9bbc86 - ImageProps, // 196f0d32 + Image, // c9d40e0a + ImageBackground, // 1ebf73eb + ImageBackgroundInstance, // 88068b4d + ImageBackgroundProps, // d4ec764b + ImageErrorEvent, // 978933f4 + ImageInstance, // 9a100753 + ImageLoadEvent, // 77f0b718 + ImageProgressEventIOS, // 445331a4 + ImageProps, // 75d78475 ImagePropsAndroid, // 9fd9bcbb - ImagePropsBase, // fdbd3b49 - ImagePropsIOS, // 32e6747c + ImagePropsBase, // 3366fcf2 + ImagePropsIOS, // 4a080668 ImageRequireSource, // 681d683b ImageResolvedAssetSource, // f3060931 ImageSize, // 1c47cf88 @@ -6034,16 +5935,17 @@ export { ImageSourcePropType, // bfb5e5c6 ImageStyle, // ad6a6dee ImageURISource, // 016eb083 - InputAccessoryView, // d664987a + InputAccessoryView, // 0b924b84 InputAccessoryViewProps, // ac36060b InputModeOptions, // 4e8581b9 Insets, // e7fe432a - KeyDownEvent, // e446406b + KeyDownEvent, // 5b147614 KeyEvent, // 20fa4267 - KeyUpEvent, // d4b54d8e + KeyUpEvent, // 57f832c5 Keyboard, // 49414c97 - KeyboardAvoidingView, // 6192aeef - KeyboardAvoidingViewProps, // 7c8e6d80 + KeyboardAvoidingView, // f612e39b + KeyboardAvoidingViewInstance, // 084c1430 + KeyboardAvoidingViewProps, // 8f05bdcc KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 KeyboardEventName, // 59299ad6 @@ -6056,7 +5958,7 @@ export { LayoutAnimationProperty, // 52995f01 LayoutAnimationType, // 2da0a29b LayoutAnimationTypes, // 081b3bde - LayoutChangeEvent, // b0cb1b07 + LayoutChangeEvent, // 98960b70 LayoutConformanceProps, // 055f03b8 LayoutRectangle, // 6601b294 Linking, // 9a6a174d @@ -6068,34 +5970,32 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // 48ace2d7 - ModalBaseProps, // ad1ae814 - ModalProps, // 04199141 + Modal, // 2ae8076c + ModalBaseProps, // 71945951 + ModalInstance, // d466ce77 + ModalProps, // 96a029e2 ModalPropsAndroid, // 515fb173 - ModalPropsIOS, // c16dab61 - ModeChangeEvent, // b030f9be - MouseEvent, // a33f8058 + ModalPropsIOS, // 0e13cfcc + ModeChangeEvent, // f64bf69d + MouseEvent, // d1f889fd NativeAppEventEmitter, // 08d4c47d NativeColorValue, // d2094c29 - NativeComponentRegistry, // 6497d2b6 - NativeDialogManagerAndroid, // 5be8497e + NativeComponentRegistry, // c8fc2fb5 NativeEventEmitter, // 27f97c1a NativeEventSubscription, // de3942e7 - NativeMethods, // ce1a8622 - NativeMethodsMixin, // 6127a27d NativeModules, // 4597cd36 - NativeMouseEvent, // ddcc5836 - NativePointerEvent, // 49e97dbb + NativeMouseEvent, // 16c856a5 + NativePointerEvent, // 64ff2151 NativeScrollEvent, // caad7f53 - NativeSyntheticEvent, // 99ec1d60 + NativeSyntheticEvent, // 534aaa92 NativeTouchEvent, // 59b676df NativeUIEvent, // 44ac26ac Networking, // bbc5be42 OpaqueColorValue, // 25f3fa5b - PanResponder, // ff2437d5 - PanResponderCallbacks, // 315230b0 + PanResponder, // f8f71cac + PanResponderCallbacks, // 6d63e7be PanResponderGestureState, // 54baf558 - PanResponderInstance, // 51c64e49 + PanResponderInstance, // 69cebbe8 Permission, // 06473f4f PermissionStatus, // 4b7de97b PermissionsAndroid, // db2a401e @@ -6105,29 +6005,32 @@ export { PlatformOSType, // 0a17561e PlatformSelectSpec, // 09ed7758 PointValue, // 69db075f - PointerEvent, // 8dd8fcfd - PressabilityConfig, // cf525d89 - PressabilityEventHandlers, // 8fcdfdf6 - Pressable, // 6039f73a + PointerEvent, // ff599afe + PressabilityConfig, // faab5639 + PressabilityEventHandlers, // 0b910091 + Pressable, // 1317b500 PressableAndroidRippleConfig, // ee32eaca - PressableProps, // 13d5a2f1 + PressableInstance, // eebfe911 + PressableProps, // fa87db54 PressableStateCallbackType, // 9af36561 ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // 3ea5543a - ProgressBarAndroidProps, // 84635506 + ProgressBarAndroid, // 5fe46213 + ProgressBarAndroidInstance, // ab545ef1 + ProgressBarAndroidProps, // d83cd71f PublicRootInstance, // 8040afd7 - PublicTextInstance, // 265237c6 + PublicTextInstance, // 6937c7bf PushNotificationEventName, // 84e7e150 PushNotificationIOS, // b4d1fe78 PushNotificationPermissions, // c2e7ae4f Rationale, // 5df1b1c1 ReactNativeVersion, // abd76827 - RefreshControl, // 068b1015 - RefreshControlProps, // 1b07a4c7 + RefreshControl, // 36c129c8 + RefreshControlInstance, // be7161ec + RefreshControlProps, // d564221a RefreshControlPropsAndroid, // 99f64c97 RefreshControlPropsIOS, // 72a36381 Registry, // 6c39216d - ResponderSyntheticEvent, // 57478720 + ResponderSyntheticEvent, // ebfa7f48 ReturnKeyTypeOptions, // afd47ba3 Role, // af7b889d RootTag, // 3cd10504 @@ -6135,23 +6038,26 @@ export { RootViewStyleProvider, // d4818465 Runnable, // 594dd93a Runnables, // 4367c557 - SafeAreaView, // 13e5d7d8 + SafeAreaView, // 0bfa1f1d + SafeAreaViewInstance, // 21dba39c ScaledSize, // 07e417c7 - ScrollEvent, // 68939866 - ScrollResponderType, // f696d6fb + ScrollEvent, // d7abdd0a + ScrollResponderType, // 3991d0ad ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // 21775fc8 - ScrollViewImperativeMethods, // 314462c7 - ScrollViewProps, // 3354a492 + ScrollView, // f493b5d4 + ScrollViewImperativeMethods, // 2791f991 + ScrollViewInstance, // 8a170aaf + ScrollViewProps, // 346eb88e ScrollViewPropsAndroid, // 44210553 - ScrollViewPropsIOS, // 7ca110e7 + ScrollViewPropsIOS, // b7921e26 ScrollViewScrollToOptions, // 3313411e - SectionBase, // b376bddc - SectionList, // f04d848d - SectionListData, // 119baf83 - SectionListProps, // 9c8b2b1e - SectionListRenderItem, // 1fad0435 - SectionListRenderItemInfo, // 745e1992 + SectionBase, // dca83594 + SectionList, // 876f013f + SectionListData, // e0d79987 + SectionListInstance, // dbdba666 + SectionListProps, // 8bd0ac05 + SectionListRenderItem, // 466e3e87 + SectionListRenderItemInfo, // d809238e Separators, // 6a45f7e3 Settings, // 2be0c61e Share, // e4591b32 @@ -6162,71 +6068,81 @@ export { ShareOptions, // 800c3a4e StatusBar, // 875b4eca StatusBarAnimation, // 7fd047e6 + StatusBarInstance, // 045e0c50 StatusBarProps, // b72a9127 StatusBarStyle, // 78f53eea StyleProp, // fa0e9b4a StyleSheet, // e77dd046 SubmitBehavior, // c4ddf490 - Switch, // bf145836 - SwitchChangeEvent, // f3013e4e - SwitchProps, // 9b60edbf + Switch, // 135ac108 + SwitchChangeEvent, // 899635b1 + SwitchInstance, // 3c50eec5 + SwitchProps, // 7a40abb7 Systrace, // 626d178c TVViewPropsIOS, // 330ce7b5 TargetedEvent, // 16e98910 TaskProvider, // 266dedf2 - Text, // 0937861d + Text, // 3f8db3e4 TextContentType, // 239b3ecc - TextInput, // ee8f6f5d + TextInput, // a9331dee TextInputAndroidProps, // 3f09ce49 - TextInputChangeEvent, // b5264e88 - TextInputContentSizeChangeEvent, // a6612e5e - TextInputEndEditingEvent, // ffeb6ebd - TextInputFocusEvent, // 6ae5be45 + TextInputChangeEvent, // f55eef98 + TextInputContentSizeChangeEvent, // a27cd32a + TextInputEndEditingEvent, // e690b56b + TextInputFocusEvent, // 19851a88 TextInputIOSProps, // 0d05a855 - TextInputKeyPressEvent, // fcead0c9 - TextInputProps, // 0fa27aa2 - TextInputSelectionChangeEvent, // 1a6383cf - TextInputSubmitEditingEvent, // e3152e2d - TextLayoutEvent, // c3e8821d - TextProps, // fb3a9124 + TextInputInstance, // 5a0c0e0d + TextInputKeyPressEvent, // 546c5d07 + TextInputProps, // c034b351 + TextInputSelectionChangeEvent, // e58f2abc + TextInputSubmitEditingEvent, // 6bcb2aa5 + TextInstance, // 05463a96 + TextLayoutEvent, // 3f54186f + TextProps, // 18d5fd16 TextStyle, // bb9b7a58 ToastAndroid, // 88a8969a - Touchable, // a05e8365 - TouchableHighlight, // 4f247d12 - TouchableHighlightProps, // 384d8d78 - TouchableNativeFeedback, // 855953dc - TouchableNativeFeedbackProps, // 1d2c2871 - TouchableOpacity, // eab90960 - TouchableOpacityProps, // 38265cbb - TouchableWithoutFeedback, // f000a22f - TouchableWithoutFeedbackProps, // e7f63a63 + Touchable, // b280637f + TouchableHighlight, // 7e5ec9c5 + TouchableHighlightInstance, // b510c0eb + TouchableHighlightProps, // 09dc3407 + TouchableNativeFeedback, // d18394ba + TouchableNativeFeedbackInstance, // 74dc04e1 + TouchableNativeFeedbackProps, // 98677960 + TouchableOpacity, // 16b54a1a + TouchableOpacityInstance, // b186055b + TouchableOpacityProps, // aa6b543f + TouchableWithoutFeedback, // 56a6ea8f + TouchableWithoutFeedbackProps, // 482dfc28 TransformsStyle, // 65e70f18 TurboModule, // dfe29706 TurboModuleRegistry, // 4ace6db2 UIManager, // a1a7cc01 UTFSequence, // ad625158 Vibration, // 31e4bbf8 - View, // 5a1289a3 - ViewProps, // 1c9bc89c - ViewPropsAndroid, // b95e4831 + View, // c5b3d5fe + ViewInstance, // ffde5573 + ViewProps, // a50b7cfa + ViewPropsAndroid, // 03c17367 ViewPropsIOS, // 58ee19bf ViewStyle, // 00a0f8fb VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e - VirtualizedListProps, // cb75c897 + VirtualizedListInstance, // 423ee7c0 + VirtualizedListProps, // a5458c31 VirtualizedSectionList, // 9fd9cd61 - VirtualizedSectionListProps, // e037ec57 - WrapperComponentProvider, // 9cf3844c + VirtualizedSectionListInstance, // 12b706d5 + VirtualizedSectionListProps, // ef387a8a + WrapperComponentProvider, // 4b8c7962 codegenNativeCommands, // 628a7c0a - codegenNativeComponent, // 65335a0c + codegenNativeComponent, // 32a1bca6 findNodeHandle, // 93f80214 processColor, // 6e877698 registerCallableModule, // 839c8cfe - requireNativeComponent, // 35636f3c + requireNativeComponent, // aa36a6dd useAnimatedColor, // e3511f81 useAnimatedValue, // b18adb63 useAnimatedValueXY, // c7ee2332 useColorScheme, // d585efdb - usePressability, // 581a946a + usePressability, // 095343b5 useWindowDimensions, // bb4b683f } diff --git a/packages/react-native/index.js b/packages/react-native/index.js index 20f2c827680e..22bc46dd45b3 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -275,10 +275,6 @@ module.exports = { get NativeComponentRegistry() { return require('./Libraries/NativeComponent/NativeComponentRegistry'); }, - get NativeDialogManagerAndroid() { - return require('./Libraries/NativeModules/specs/NativeDialogManagerAndroid') - .default; - }, get NativeEventEmitter() { return require('./Libraries/EventEmitter/NativeEventEmitter').default; }, diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index b0a636234c61..f5558ea6448a 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 @@ -310,8 +343,6 @@ export {default as NativeAppEventEmitter} from './Libraries/EventEmitter/RCTNati export * as NativeComponentRegistry from './Libraries/NativeComponent/NativeComponentRegistry'; -export {default as NativeDialogManagerAndroid} from './Libraries/NativeModules/specs/NativeDialogManagerAndroid'; - export type { EmitterSubscription, NativeEventSubscription, @@ -448,8 +479,6 @@ export type * from './Libraries/Types/CodegenTypesNamespace'; export type { HostInstance, - NativeMethods, - NativeMethodsMixin, MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, diff --git a/packages/react-native/src/private/types/HostInstance.js b/packages/react-native/src/private/types/HostInstance.js index cb7dff7dcc44..413b7076380f 100644 --- a/packages/react-native/src/private/types/HostInstance.js +++ b/packages/react-native/src/private/types/HostInstance.js @@ -35,85 +35,43 @@ export type MeasureLayoutOnSuccessCallback = ( ) => void; /** - * NativeMethods provides methods to access the underlying native component directly. - * This can be useful in cases when you want to focus a view or measure its on-screen dimensions, - * for example. - * The methods described here are available on most of the default components provided by React Native. - * Note, however, that they are not available on composite components that aren't directly backed by a - * native view. This will generally include most components that you define in your own app. - * For more information, see [Direct Manipulation](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture). - * @see https://github.com/facebook/react-native/blob/master/Libraries/Renderer/shims/ReactNativeTypes.js#L87 + * Represents an instance of a React Native host component — i.e. a component + * directly backed by a native view (e.g. ``, ``, ``). + * + * `HostInstance` is an alias for `ReactNativeElement`, which exposes a + * DOM-compatible element interface. This aligns with the New Architecture's + * approach of surfacing W3C-compatible APIs for direct manipulation of native + * views. + * + * @remarks + * **Prefer component-specific `*Instance` types for refs.** + * For most use cases, import the dedicated instance type for the component + * you're working with rather than using `HostInstance` directly: + * + * ```tsx + * import type { ViewInstance, TextInputInstance } from 'react-native'; + * + * const viewRef = useRef(null); + * const inputRef = useRef(null); + * ``` + * + * `HostInstance` is the correct choice for **library authors** writing + * component-agnostic utilities that accept any native element ref. For + * application code targeting a specific component, `HostInstance` silently + * loses access to component-specific imperative methods (e.g. + * `TextInputInstance.clear()`, `ScrollViewInstance.scrollTo()`). + * + * **Only available on host components.** Composite components — including most + * app-defined components — do not expose a `HostInstance` unless they forward + * a ref to an underlying host component via `React.forwardRef`. + * + * **Avoid direct manipulation where possible.** Prefer `setState` and + * controlled props. Direct manipulation bypasses React's reconciliation and + * can cause subtle conflicts if the same property is also managed via props. + * The primary valid use case is performance-sensitive scenarios such as + * continuous animations, where triggering a full re-render on every frame + * would introduce unacceptable overhead. + * + * @see {@link https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture | Direct Manipulation} */ -export interface LegacyHostInstanceMethods { - /** - * Removes focus from an input or view. This is the opposite of `focus()`. - */ - blur(): void; - /** - * Requests focus for the given input or view. The exact behavior triggered - * will depend on the platform and type of view. - */ - focus(): void; - /** - * Determines the location on screen, width, and height of the given view and - * returns the values via an async callback. If successful, the callback will - * be called with the following arguments: - * - * - x - * - y - * - width - * - height - * - pageX - * - pageY - * - * Note that these measurements are not available until after the rendering - * has been completed in native. If you need the measurements as soon as - * possible, consider using the [`onLayout` - * prop](docs/view.html#onlayout) instead. - */ - measure(callback: MeasureOnSuccessCallback): void; - /** - * Determines the location of the given view in the window and returns the - * values via an async callback. If the React root view is embedded in - * another native view, this will give you the absolute coordinates. If - * successful, the callback will be called with the following - * arguments: - * - * - x - * - y - * - width - * - height - * - * Note that these measurements are not available until after the rendering - * has been completed in native. - */ - measureInWindow(callback: MeasureInWindowOnSuccessCallback): void; - /** - * Like [`measure()`](#measure), but measures the view relative an ancestor, - * specified as `relativeToNativeComponentRef`. This means that the returned x, y - * are relative to the origin x, y of the ancestor view. - * _Can also be called with a relativeNativeNodeHandle but is deprecated._ - */ - measureLayout( - relativeToNativeNode: number | HostInstance, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail?: () => void, - ): void; - /** - * This function sends props straight to native. They will not participate in - * future diff process - this means that if you do not include them in the - * next render, they will remain active (see [Direct - * Manipulation](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture)). - */ - setNativeProps(nativeProps: {...}): void; -} - export type HostInstance = ReactNativeElement; - -/** @deprecated Use HostInstance instead */ -export type NativeMethods = LegacyHostInstanceMethods; - -/** - * @deprecated Use HostInstance instead. - */ -export type NativeMethodsMixin = LegacyHostInstanceMethods; diff --git a/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js b/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js index 01e65cfba575..21c7067e8592 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js +++ b/packages/react-native/src/private/webapis/dom/nodes/ReactNativeElement.js @@ -19,7 +19,6 @@ import type { MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, MeasureOnSuccessCallback, - NativeMethods, } from '../../../types/HostInstance'; import type Event from '../events/Event'; import type {InstanceHandle} from './internals/NodeInternals'; @@ -68,7 +67,7 @@ const noop = () => {}; // we then discard to create a new one. /** @build-types protected-constructor */ -class ReactNativeElement extends ReadOnlyElement implements NativeMethods { +class ReactNativeElement extends ReadOnlyElement { // These need to be accessible from `ReactFabricPublicInstanceUtils`. __nativeTag: number; __internalInstanceHandle: InstanceHandle; @@ -150,6 +149,9 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { * React Native compatibility methods */ + /** + * Removes focus from an input or view. This is the opposite of `focus()`. + */ blur(): void { if (TextInputState.isTextInput(this)) { TextInputState.blurTextInput(this); @@ -158,6 +160,10 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { } } + /** + * Requests focus for the given input or view. The exact behavior triggered + * will depend on the platform and type of view. + */ focus() { if (TextInputState.isTextInput(this)) { TextInputState.focusTextInput(this); @@ -166,6 +172,23 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { } } + /** + * Determines the location on screen, width, and height of the given view and + * returns the values via an async callback. If successful, the callback will + * be called with the following arguments: + * + * - x + * - y + * - width + * - height + * - pageX + * - pageY + * + * Note that these measurements are not available until after the rendering + * has been completed in native. If you need the measurements as soon as + * possible, consider using the [`onLayout` + * prop](docs/view.html#onlayout) instead. + */ measure(callback: MeasureOnSuccessCallback) { const node = getNativeElementReference(this); if (node != null) { @@ -173,6 +196,21 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { } } + /** + * Determines the location of the given view in the window and returns the + * values via an async callback. If the React root view is embedded in + * another native view, this will give you the absolute coordinates. If + * successful, the callback will be called with the following + * arguments: + * + * - x + * - y + * - width + * - height + * + * Note that these measurements are not available until after the rendering + * has been completed in native. + */ measureInWindow(callback: MeasureInWindowOnSuccessCallback) { const node = getNativeElementReference(this); if (node != null) { @@ -180,6 +218,12 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { } } + /** + * Like [`measure()`](#measure), but measures the view relative an ancestor, + * specified as `relativeToNativeComponentRef`. This means that the returned x, y + * are relative to the origin x, y of the ancestor view. + * _Can also be called with a relativeNativeNodeHandle but is deprecated._ + */ measureLayout( relativeToNativeNode: number | HostInstance, onSuccess: MeasureLayoutOnSuccessCallback, @@ -208,6 +252,12 @@ class ReactNativeElement extends ReadOnlyElement implements NativeMethods { } } + /** + * This function sends props straight to native. They will not participate in + * future diff process - this means that if you do not include them in the + * next render, they will remain active (see [Direct + * Manipulation](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture)). + */ setNativeProps(nativeProps: {...}): void { if (__DEV__) { warnForStyleProps(nativeProps, this.__viewConfig.validAttributes); diff --git a/packages/react-native/types/public/ReactNativeTypes.d.ts b/packages/react-native/types/public/ReactNativeTypes.d.ts index 3feb5b2d718d..74d7602d017a 100644 --- a/packages/react-native/types/public/ReactNativeTypes.d.ts +++ b/packages/react-native/types/public/ReactNativeTypes.d.ts @@ -41,6 +41,8 @@ export type MeasureLayoutOnSuccessCallback = ( * native view. This will generally include most components that you define in your own app. * For more information, see [Direct Manipulation](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture). * @see https://github.com/facebook/react-native/blob/master/Libraries/Renderer/shims/ReactNativeTypes.js#L87 + * + * @deprecated Use HostInstance instead. */ export interface NativeMethods { /** @@ -112,11 +114,11 @@ export interface NativeMethods { } /** - * @deprecated Use NativeMethods instead. + * @deprecated Use HostInstance instead. */ export type NativeMethodsMixin = NativeMethods; /** - * @deprecated Use NativeMethods instead. + * @deprecated Use HostInstance instead. */ export type NativeMethodsMixinType = NativeMethods;