diff --git a/packages/eslint-plugin-react-native/utils.js b/packages/eslint-plugin-react-native/utils.js index 01c41d361b6..98d1e90ca0b 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/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index 2d8c0e42d67..190d559a711 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 501df15989b..da6972e835d 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/TextProps.js b/packages/react-native/Libraries/Text/TextProps.js index d6be6a5658c..52925d61107 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 a34c29584d9..77dde28fd8d 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<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -86,7 +86,6 @@ 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 @@ -287,7 +286,6 @@ 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 @@ -985,7 +983,6 @@ 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 @@ -1956,17 +1953,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 @@ -2972,18 +2958,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: [ @@ -3213,7 +3187,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 +3229,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: { @@ -4005,10 +3976,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 @@ -4671,20 +4639,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: ( @@ -5043,6 +4997,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 @@ -5599,7 +5554,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 } @@ -5942,23 +5897,23 @@ 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, // a8081184 + ActivityIndicatorProps, // 410756e8 Alert, // 5bf12165 AlertButton, // bf1a3b60 AlertButtonStyle, // ec9fb242 AlertOptions, // a0cdac0f AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // d3264d4b + Animated, // a08d51f6 AppConfig, // ce4209a7 AppRegistry, // 5edf0524 AppState, // 12012be5 @@ -5968,12 +5923,12 @@ export { AutoCapitalize, // c0e857a0 BackHandler, // f139fc69 BackPressEventName, // 4620fb76 - BlurEvent, // 4d39aa26 + BlurEvent, // 4ba4f941 BoxShadowValue, // b679703f - Button, // 2a455f1c - ButtonProps, // b276cb7a + Button, // c99c04a1 + ButtonProps, // 35ffc98c Clipboard, // 41addb89 - CodegenTypes, // 51ca21ff + CodegenTypes, // ab4986cc ColorSchemeName, // 6615edd6 ColorValue, // 98989a8f ComponentProvider, // b5c60ddd @@ -5989,9 +5944,9 @@ export { DimensionsPayload, // 653bc26c DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb - DrawerLayoutAndroid, // 3939f773 - DrawerLayoutAndroidProps, // ec039f19 - DrawerSlideEvent, // 6a679d9c + DrawerLayoutAndroid, // 4dcb4a45 + DrawerLayoutAndroidProps, // 2f0e6568 + DrawerSlideEvent, // c4ab8fba DropShadowValue, // e9df2606 DynamicColorIOS, // d96c228c DynamicColorIOSTuple, // 023ce58e @@ -6005,28 +5960,28 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // fda604e6 - FlatListProps, // 4386b761 - FocusEvent, // 4fab86b8 + FlatList, // ac5028e5 + FlatListProps, // 45c80abb + 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 + ImageBackgroundProps, // d4ec764b + ImageErrorEvent, // 978933f4 + ImageLoadEvent, // 77f0b718 + ImageProgressEventIOS, // 445331a4 + ImageProps, // 75d78475 ImagePropsAndroid, // 9fd9bcbb - ImagePropsBase, // fdbd3b49 - ImagePropsIOS, // 32e6747c + ImagePropsBase, // 3366fcf2 + ImagePropsIOS, // 4a080668 ImageRequireSource, // 681d683b ImageResolvedAssetSource, // f3060931 ImageSize, // 1c47cf88 @@ -6038,12 +5993,12 @@ export { InputAccessoryViewProps, // ac36060b InputModeOptions, // 4e8581b9 Insets, // e7fe432a - KeyDownEvent, // e446406b + KeyDownEvent, // 5b147614 KeyEvent, // 20fa4267 - KeyUpEvent, // d4b54d8e + KeyUpEvent, // 57f832c5 Keyboard, // 49414c97 - KeyboardAvoidingView, // 6192aeef - KeyboardAvoidingViewProps, // 7c8e6d80 + KeyboardAvoidingView, // d631fd5d + KeyboardAvoidingViewProps, // 8f05bdcc KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 KeyboardEventName, // 59299ad6 @@ -6056,7 +6011,7 @@ export { LayoutAnimationProperty, // 52995f01 LayoutAnimationType, // 2da0a29b LayoutAnimationTypes, // 081b3bde - LayoutChangeEvent, // b0cb1b07 + LayoutChangeEvent, // 98960b70 LayoutConformanceProps, // 055f03b8 LayoutRectangle, // 6601b294 Linking, // 9a6a174d @@ -6068,34 +6023,31 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // 48ace2d7 - ModalBaseProps, // ad1ae814 - ModalProps, // 04199141 + Modal, // e17d2233 + ModalBaseProps, // 4f5d96ce + ModalProps, // d6e3ba7c ModalPropsAndroid, // 515fb173 - ModalPropsIOS, // c16dab61 - ModeChangeEvent, // b030f9be - MouseEvent, // a33f8058 + ModalPropsIOS, // 0e13cfcc + ModeChangeEvent, // f64bf69d + MouseEvent, // d1f889fd NativeAppEventEmitter, // 08d4c47d NativeColorValue, // d2094c29 - NativeComponentRegistry, // 6497d2b6 - NativeDialogManagerAndroid, // 5be8497e + NativeComponentRegistry, // 739b86a9 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 +6057,29 @@ export { PlatformOSType, // 0a17561e PlatformSelectSpec, // 09ed7758 PointValue, // 69db075f - PointerEvent, // 8dd8fcfd - PressabilityConfig, // cf525d89 - PressabilityEventHandlers, // 8fcdfdf6 - Pressable, // 6039f73a + PointerEvent, // ff599afe + PressabilityConfig, // faab5639 + PressabilityEventHandlers, // 0b910091 + Pressable, // 48ee8465 PressableAndroidRippleConfig, // ee32eaca - PressableProps, // 13d5a2f1 + PressableProps, // fa87db54 PressableStateCallbackType, // 9af36561 ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // 3ea5543a - ProgressBarAndroidProps, // 84635506 + ProgressBarAndroid, // 5d3bd063 + ProgressBarAndroidProps, // d83cd71f PublicRootInstance, // 8040afd7 - PublicTextInstance, // 265237c6 + PublicTextInstance, // 6937c7bf PushNotificationEventName, // 84e7e150 PushNotificationIOS, // b4d1fe78 PushNotificationPermissions, // c2e7ae4f Rationale, // 5df1b1c1 ReactNativeVersion, // abd76827 - RefreshControl, // 068b1015 - RefreshControlProps, // 1b07a4c7 + RefreshControl, // 36c129c8 + RefreshControlProps, // d564221a RefreshControlPropsAndroid, // 99f64c97 RefreshControlPropsIOS, // 72a36381 Registry, // 6c39216d - ResponderSyntheticEvent, // 57478720 + ResponderSyntheticEvent, // ebfa7f48 ReturnKeyTypeOptions, // afd47ba3 Role, // af7b889d RootTag, // 3cd10504 @@ -6135,21 +6087,21 @@ export { RootViewStyleProvider, // d4818465 Runnable, // 594dd93a Runnables, // 4367c557 - SafeAreaView, // 13e5d7d8 + SafeAreaView, // 6cdc4369 ScaledSize, // 07e417c7 - ScrollEvent, // 68939866 - ScrollResponderType, // f696d6fb + ScrollEvent, // d7abdd0a + ScrollResponderType, // b453c82d ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // 21775fc8 - ScrollViewImperativeMethods, // 314462c7 - ScrollViewProps, // 3354a492 + ScrollView, // bd2b79e6 + ScrollViewImperativeMethods, // 3699615e + ScrollViewProps, // 7bd4ce90 ScrollViewPropsAndroid, // 44210553 - ScrollViewPropsIOS, // 7ca110e7 + ScrollViewPropsIOS, // b7921e26 ScrollViewScrollToOptions, // 3313411e SectionBase, // b376bddc - SectionList, // f04d848d + SectionList, // 2775c971 SectionListData, // 119baf83 - SectionListProps, // 9c8b2b1e + SectionListProps, // ca4b5d20 SectionListRenderItem, // 1fad0435 SectionListRenderItemInfo, // 745e1992 Separators, // 6a45f7e3 @@ -6167,66 +6119,66 @@ export { StyleProp, // fa0e9b4a StyleSheet, // e77dd046 SubmitBehavior, // c4ddf490 - Switch, // bf145836 - SwitchChangeEvent, // f3013e4e - SwitchProps, // 9b60edbf + Switch, // 07e544e2 + SwitchChangeEvent, // 899635b1 + SwitchProps, // 7a40abb7 Systrace, // 626d178c TVViewPropsIOS, // 330ce7b5 TargetedEvent, // 16e98910 TaskProvider, // 266dedf2 - Text, // 0937861d + Text, // bcb334ba TextContentType, // 239b3ecc - TextInput, // ee8f6f5d + TextInput, // 2bc044b9 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 + TextInputKeyPressEvent, // 546c5d07 + TextInputProps, // 65e8bbd7 + TextInputSelectionChangeEvent, // e58f2abc + TextInputSubmitEditingEvent, // 6bcb2aa5 + 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, // 0cc5abda + TouchableHighlightProps, // 91c8f20d + TouchableNativeFeedback, // d18394ba + TouchableNativeFeedbackProps, // 98677960 + TouchableOpacity, // 5ba99a18 + TouchableOpacityProps, // 1346eeb1 + TouchableWithoutFeedback, // 56a6ea8f + TouchableWithoutFeedbackProps, // 482dfc28 TransformsStyle, // 65e70f18 TurboModule, // dfe29706 TurboModuleRegistry, // 4ace6db2 UIManager, // a1a7cc01 UTFSequence, // ad625158 Vibration, // 31e4bbf8 - View, // 5a1289a3 - ViewProps, // 1c9bc89c - ViewPropsAndroid, // b95e4831 + View, // c19ab357 + ViewProps, // a50b7cfa + ViewPropsAndroid, // 03c17367 ViewPropsIOS, // 58ee19bf ViewStyle, // 00a0f8fb VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e - VirtualizedListProps, // cb75c897 + VirtualizedListProps, // 1503dce1 VirtualizedSectionList, // 9fd9cd61 - VirtualizedSectionListProps, // e037ec57 + VirtualizedSectionListProps, // 7f01d37f WrapperComponentProvider, // 9cf3844c 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 20f2c827680..22bc46dd45b 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 b0a636234c6..88a095aa046 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -310,8 +310,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 +446,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 cb7dff7dcc4..9595bc2f77f 100644 --- a/packages/react-native/src/private/types/HostInstance.js +++ b/packages/react-native/src/private/types/HostInstance.js @@ -35,85 +35,41 @@ 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. + * + * Obtain a `HostInstance` via a ref attached to a host component: + * + * ```tsx + * const ref = useRef(null); + * + * ``` + * + * You can then call DOM-like methods on the instance — for example, to measure + * layout or imperatively focus a view: + * + * ```ts + * ref.current?.measure((x, y, width, height) => { ... }); + * ref.current?.focus(); + * ``` + * + * @remarks + * - Only available on **host components** (components backed by a native view). + * Composite components — including most app-defined components — do not + * expose a `HostInstance` unless they forward a ref to an underlying host + * component via `forwardRef`. + * - Prefer `setState` and controlled props over direct manipulation where + * possible. Direct manipulation bypasses React's reconciliation and can cause + * subtle conflicts if the same property is also managed via props. + * - `setNativeProps` is the primary escape hatch for performance-sensitive + * cases, such as continuous animations, where triggering a full re-render + * 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 01e65cfba57..21c7067e859 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 3feb5b2d718..74d7602d017 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;