From 786542b49b628b4860d48c8ebc7741d5505e2e66 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 9 Sep 2026 11:39:56 +0200 Subject: [PATCH] Revert "Remove Touchable (base) from public API (#57476)" This reverts commit 6fbf3062f9085c93bcb35c6a61c76029abbc16a5. --- packages/react-native/ReactNativeApi.d.ts | 60 ++++++++++++++++++- packages/react-native/__typetests__/index.tsx | 17 ++++++ packages/react-native/index.js | 18 +----- packages/react-native/index.js.flow | 2 + 4 files changed, 79 insertions(+), 18 deletions(-) diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index e1654b681c24..4e0abdd0cdab 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<86dc0a1f6f841ce7290c8f7443746794>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -320,7 +320,12 @@ declare const Pressable: typeof MemoedPressable_default declare const processColor: typeof processColor_default declare const ProgressBarAndroid: typeof ProgressBarAndroid_default declare let ProgressBarAndroid_default: ( - props: Omit_2, "ref"> & { + props: Omit_2< + Omit_2, + keyof { + ref?: React.Ref + } + > & { ref?: React.Ref }, ) => React.ReactNode @@ -394,6 +399,16 @@ declare const staggerImpl: ( time: number, animations: Array, ) => CompositeAnimation +declare const States: { + ERROR: "ERROR" + NOT_RESPONDER: "NOT_RESPONDER" + RESPONDER_ACTIVE_LONG_PRESS_IN: "RESPONDER_ACTIVE_LONG_PRESS_IN" + RESPONDER_ACTIVE_LONG_PRESS_OUT: "RESPONDER_ACTIVE_LONG_PRESS_OUT" + RESPONDER_ACTIVE_PRESS_IN: "RESPONDER_ACTIVE_PRESS_IN" + RESPONDER_ACTIVE_PRESS_OUT: "RESPONDER_ACTIVE_PRESS_OUT" + RESPONDER_INACTIVE_PRESS_IN: "RESPONDER_INACTIVE_PRESS_IN" + RESPONDER_INACTIVE_PRESS_OUT: "RESPONDER_INACTIVE_PRESS_OUT" +} declare const subtract: typeof $$AnimatedImplementation.subtract declare const subtractImpl: ( a: AnimatedNode_default | number, @@ -435,6 +450,7 @@ declare const ToastAndroid_default: { yOffset: number, ) => void } +declare const Touchable: typeof TouchableImpl_default declare const Touchable_default: ( props: TouchableOpacityProps & { ref?: React.Ref @@ -446,6 +462,33 @@ declare const TouchableHighlight_default: ( ref?: React.Ref }, ) => React.ReactNode +declare const TouchableImpl_default: { + Mixin: typeof TouchableMixinImpl + renderDebugView: ($$PARAM_0$$: { + color: ColorValue + hitSlop?: EdgeInsetsProp + }) => null | React.ReactNode +} +declare const TouchableMixinImpl: { + withoutDefaultFocusAndBlur: {} + componentDidMount: () => void + componentWillUnmount: () => void + touchableGetInitialState: () => { + touchable: { + responderID: GestureResponderEvent["currentTarget"] | undefined + touchState: TouchableState | undefined + } + } + touchableHandleBlur: (e: BlurEvent) => void + touchableHandleFocus: (e: FocusEvent) => void + touchableHandleResponderGrant: (e: GestureResponderEvent) => void + touchableHandleResponderMove: (e: GestureResponderEvent) => void + touchableHandleResponderRelease: (e: GestureResponderEvent) => void + touchableHandleResponderTerminate: (e: GestureResponderEvent) => void + touchableHandleResponderTerminationRequest: () => boolean + touchableHandleStartShouldSetResponder: () => boolean + touchableLongPressCancelsPress: () => boolean +} declare const TouchableOpacity: typeof Touchable_default declare const UIManager: typeof UIManager_default declare const UIManager_default: UIManagerJSInterface @@ -5222,6 +5265,7 @@ declare type TimingAnimationConfig = Readonly< } > declare type ToastAndroid = typeof ToastAndroid +declare type Touchable = typeof Touchable declare type TouchableHighlight = typeof TouchableHighlight declare type TouchableHighlightBaseProps = { readonly activeOpacity?: number @@ -5326,6 +5370,15 @@ declare type TouchableOpacityTVProps = { readonly nextFocusRight?: number readonly nextFocusUp?: number } +declare type TouchableState = + | typeof States.ERROR + | typeof States.NOT_RESPONDER + | typeof States.RESPONDER_ACTIVE_LONG_PRESS_IN + | typeof States.RESPONDER_ACTIVE_LONG_PRESS_OUT + | typeof States.RESPONDER_ACTIVE_PRESS_IN + | typeof States.RESPONDER_ACTIVE_PRESS_OUT + | typeof States.RESPONDER_INACTIVE_PRESS_IN + | typeof States.RESPONDER_INACTIVE_PRESS_OUT declare function TouchableWithoutFeedback( props: TouchableWithoutFeedbackProps, ): React.ReactNode @@ -5921,7 +5974,7 @@ export { PressableProps, // 573ac60a PressableStateCallbackType, // 5e0cfa78 ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // db8f6a6b + ProgressBarAndroid, // 88dcf080 ProgressBarAndroidInstance, // ab545ef1 ProgressBarAndroidProps, // 6484d368 PublicRootInstance, // 8040afd7 @@ -6009,6 +6062,7 @@ export { TextProps, // 2e3336ca TextStyle, // d7678842 ToastAndroid, // 88a8969a + Touchable, // 1cac925a TouchableHighlight, // edab1b07 TouchableHighlightInstance, // b510c0eb TouchableHighlightProps, // 08cd59e1 diff --git a/packages/react-native/__typetests__/index.tsx b/packages/react-native/__typetests__/index.tsx index 54ea8b7694ba..1df236c3bc71 100644 --- a/packages/react-native/__typetests__/index.tsx +++ b/packages/react-native/__typetests__/index.tsx @@ -124,6 +124,7 @@ import { // @ts-ignore SectionListData, ToastAndroid, + Touchable, LayoutAnimation, processColor, experimental_LayoutConformance as LayoutConformance, @@ -486,6 +487,22 @@ class Welcome extends React.Component< export default Welcome; +// TouchableTest +function TouchableTest() { + function basicUsage() { + return Touchable.renderDebugView({ + color: 'mediumspringgreen', + hitSlop: {bottom: 5, top: 5}, + }); + } + + function defaultHitSlop() { + return Touchable.renderDebugView({ + color: 'red', + }); + } +} + export class TouchableHighlightTest extends React.Component { buttonRef = React.createRef>(); diff --git a/packages/react-native/index.js b/packages/react-native/index.js index 80fb9723e4f9..ebd0937933c0 100644 --- a/packages/react-native/index.js +++ b/packages/react-native/index.js @@ -153,6 +153,9 @@ module.exports = { get TextInput() { return require('./Libraries/Components/TextInput/TextInput').default; }, + get Touchable() { + return require('./Libraries/Components/Touchable/Touchable').default; + }, get TouchableHighlight() { return require('./Libraries/Components/Touchable/TouchableHighlight') .default; @@ -413,21 +416,6 @@ module.exports = { // #endregion } as ReactNativePublicAPI; -// `Touchable` has been removed from the public API types, but remains -// re-exported at runtime here because of a hanging `react-native-svg` call -// site (fbsource). -// TODO(huntie): Remove this re-export once `react-native-svg` is updated. -/* $FlowFixMe[prop-missing] This is intentional: `Touchable` is a value-only - * re-export that is absent from the public API types. */ -/* $FlowFixMe[invalid-export] This is intentional: `Touchable` is a value-only - * re-export that is absent from the public API types. */ -Object.defineProperty(module.exports, 'Touchable', { - configurable: true, - get() { - return require('./Libraries/Components/Touchable/Touchable').default; - }, -}); - if (__DEV__) { /* $FlowFixMe[prop-missing] This is intentional: Flow will error when * attempting to access InteractionManager. */ diff --git a/packages/react-native/index.js.flow b/packages/react-native/index.js.flow index 51e4a54e0552..9869ed8c5907 100644 --- a/packages/react-native/index.js.flow +++ b/packages/react-native/index.js.flow @@ -175,6 +175,8 @@ export type { } from './Libraries/Components/TextInput/TextInput'; export {default as TextInput} from './Libraries/Components/TextInput/TextInput'; +export {default as Touchable} from './Libraries/Components/Touchable/Touchable'; + export type { TouchableHighlightInstance, TouchableHighlightProps,