mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Remove Touchable (base) from public API (#57420)
Summary: Pull Request resolved: https://github.com/react/react-native/pull/57420 **Motivation** The public type for `Touchable` has zero overlap with its runtime value. This is an internal implementation object which is undocumented. https://www.internalfb.com/code/fbsource/[86267213ee84]/xplat/js/react-native-github/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts?lines=18-24 https://www.internalfb.com/code/fbsource/[86267213ee84]/xplat/js/react-native-github/packages/react-native/Libraries/Components/Touchable/Touchable.js?lines=966-986 Replaces D110483989 / https://github.com/react/react-native/pull/57419. **Impact** This is a **breaking change** with few open source consumers. The `onTouchStart` etc prop typings are part of `ViewProps` today, which is a suitable replacement. Across projects I've been testing for the Strict TypeScript API rollout, the only load bearing consumer was Uniwind — where I've sent a PR to address this. - https://github.com/uni-stack/uniwind/pull/592. Changelog: [General][Breaking] - The `Touchable` root export (undocumented) is removed. If you are extending `Touchable` as a type, please use `ViewProps` instead. Reviewed By: rubennorte Differential Revision: D110488985 fbshipit-source-id: 394e3996bb45482723a4b7b18c1cf63f49cb49c5
This commit is contained in:
1 parent
554baba159
commit
0015d1e4f9
4 files changed
+16
-72
No files matched your search
+1
-50
@@ -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<<637f1d0b012ebca68c9e020a52eb2803>>
|
||||
* @generated SignedSource<<e85dfe98c549ac9fff85a8d7b90b5fd3>>
|
||||
*
|
||||
* This file was generated by scripts/js-api/build-types/index.js.
|
||||
*/
|
||||
@@ -403,16 +403,6 @@ declare const staggerImpl: (
|
||||
time: number,
|
||||
animations: Array<CompositeAnimation>,
|
||||
) => 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,
|
||||
@@ -456,7 +446,6 @@ declare const ToastAndroid_default: {
|
||||
yOffset: number,
|
||||
) => void
|
||||
}
|
||||
declare const Touchable: typeof TouchableImpl_default
|
||||
declare const Touchable_default: (
|
||||
props: TouchableOpacityProps & {
|
||||
ref?: React.Ref<TouchableOpacityInstance>
|
||||
@@ -468,33 +457,6 @@ declare const TouchableHighlight_default: (
|
||||
ref?: React.Ref<TouchableHighlightInstance>
|
||||
},
|
||||
) => 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: () => any
|
||||
touchableHandleStartShouldSetResponder: () => any
|
||||
touchableLongPressCancelsPress: () => boolean
|
||||
}
|
||||
declare const TouchableOpacity: typeof Touchable_default
|
||||
declare const UIManager: typeof UIManager_default
|
||||
declare const UIManager_default: UIManagerJSInterface
|
||||
@@ -5371,7 +5333,6 @@ 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
|
||||
@@ -5478,15 +5439,6 @@ 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
|
||||
@@ -6174,7 +6126,6 @@ export {
|
||||
TextProps, // 58466ea1
|
||||
TextStyle, // b62b8399
|
||||
ToastAndroid, // 88a8969a
|
||||
Touchable, // c15da0a2
|
||||
TouchableHighlight, // 20ba0199
|
||||
TouchableHighlightInstance, // b510c0eb
|
||||
TouchableHighlightProps, // 337a9164
|
||||
|
||||
@@ -124,7 +124,6 @@ import {
|
||||
// @ts-ignore
|
||||
SectionListData,
|
||||
ToastAndroid,
|
||||
Touchable,
|
||||
LayoutAnimation,
|
||||
processColor,
|
||||
experimental_LayoutConformance as LayoutConformance,
|
||||
@@ -487,22 +486,6 @@ 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<React.ComponentRef<typeof TouchableHighlight>>();
|
||||
|
||||
|
||||
Vendored
+15
-3
@@ -149,9 +149,6 @@ 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;
|
||||
@@ -412,6 +409,21 @@ 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. */
|
||||
|
||||
@@ -175,8 +175,6 @@ 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,
|
||||
|
||||
Reference in new issue
Block a user