Skip to content

Commit

Permalink
Type TouchableWithoutFeedback
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D7982348

fbshipit-source-id: 409ce4a5ea8c09e58c42caf9db60117253503c4c
  • Loading branch information
elicwhite authored and facebook-github-bot committed May 13, 2018
1 parent 91c4b03 commit 0b79d1f
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions Libraries/Components/Touchable/TouchableWithoutFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,55 @@ const {
} = require('ViewAccessibility');

import type {PressEvent} from 'CoreEventTypes';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {
AccessibilityComponentType,
AccessibilityTrait,
} from 'ViewAccessibility';

const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};

type Props = $ReadOnly<{|
accessible?: boolean,
accessibilityComponentType?: AccessibilityComponentType,
accessibilityLabel?:
| null
| React$PropType$Primitive<any>
| string
| Array<any>
| any,
accessibilityTraits?: AccessibilityTrait | Array<AccessibilityTrait>,
children?: ?React.Node,
delayLongPress?: ?number,
delayPressIn?: ?number,
delayPressOut?: ?number,
disabled?: ?boolean,
hitSlop?: ?EdgeInsetsProp,
nativeID?: ?string,
onLayout?: ?Function,
onLongPress?: ?Function,
onPress?: ?Function,
onPressIn?: ?Function,
onPressOut?: ?Function,
pressRetentionOffset?: ?EdgeInsetsProp,
rejectResponderTermination?: ?boolean,
testID?: ?string,
|}>;

/**
* Do not use unless you have a very good reason. All elements that
* respond to press should have a visual feedback when touched.
*
* TouchableWithoutFeedback supports only one child.
* If you wish to have several child components, wrap them in a View.
*/
const TouchableWithoutFeedback = createReactClass({
const TouchableWithoutFeedback = ((createReactClass({
displayName: 'TouchableWithoutFeedback',
mixins: [TimerMixin, Touchable.Mixin],

propTypes: {
accessible: PropTypes.bool,
accessibilityLabel: PropTypes.node,
accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentTypes),
accessibilityTraits: PropTypes.oneOfType([
PropTypes.oneOf(AccessibilityTraits),
Expand Down Expand Up @@ -80,6 +113,9 @@ const TouchableWithoutFeedback = createReactClass({

onLongPress: PropTypes.func,

nativeID: PropTypes.string,
testID: PropTypes.string,

/**
* Delay in ms, from the start of the touch, before onPressIn is called.
*/
Expand Down Expand Up @@ -195,13 +231,10 @@ const TouchableWithoutFeedback = createReactClass({
: child.props.style;
return (React: any).cloneElement(child, {
accessible: this.props.accessible !== false,
// $FlowFixMe Invalid prop usage
accessibilityLabel: this.props.accessibilityLabel,
accessibilityComponentType: this.props.accessibilityComponentType,
accessibilityTraits: this.props.accessibilityTraits,
// $FlowFixMe Invalid prop usage
nativeID: this.props.nativeID,
// $FlowFixMe Invalid prop usage
testID: this.props.testID,
onLayout: this.props.onLayout,
hitSlop: this.props.hitSlop,
Expand All @@ -216,6 +249,6 @@ const TouchableWithoutFeedback = createReactClass({
children,
});
},
});
}): any): React.ComponentType<Props>);

module.exports = TouchableWithoutFeedback;

0 comments on commit 0b79d1f

Please # to comment.