TouchableWithoutFeedback will use child's nativeID if specified

Reviewed By: sahrens

Differential Revision: D6733834

fbshipit-source-id: 409acf8d33565aa1e6d4698fd5d2db046a6f9402
This commit is contained in:
Eli White 2018-01-19 12:50:45 -08:00 committed by Facebook Github Bot
parent 4d3519cc6a
commit 3c2bb3e90a

View File

@ -12,6 +12,7 @@
'use strict';
const EdgeInsetsPropType = require('EdgeInsetsPropType');
const NativeMethodsMixin = require('NativeMethodsMixin');
const React = require('React');
const PropTypes = require('prop-types');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
@ -45,7 +46,7 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
*/
const TouchableWithoutFeedback = createReactClass({
displayName: 'TouchableWithoutFeedback',
mixins: [TimerMixin, Touchable.Mixin],
mixins: [NativeMethodsMixin, TimerMixin, Touchable.Mixin],
propTypes: {
accessible: PropTypes.bool,
@ -159,8 +160,7 @@ const TouchableWithoutFeedback = createReactClass({
},
touchableGetLongPressDelayMS: function(): number {
return this.props.delayLongPress === 0 ? 0 :
this.props.delayLongPress || 500;
return this.props.delayLongPress != null ? this.props.delayLongPress : 500;
},
touchableGetPressOutDelayMS: function(): number {
@ -184,7 +184,8 @@ const TouchableWithoutFeedback = createReactClass({
const style = (Touchable.TOUCH_TARGET_DEBUG && child.type && child.type.displayName === 'Text') ?
[child.props.style, {color: 'red'}] :
child.props.style;
return (React: any).cloneElement(child, {
return React.cloneElement(child, {
accessible: this.props.accessible !== false,
accessibilityLabel: this.props.accessibilityLabel,
accessibilityComponentType: this.props.accessibilityComponentType,
@ -193,6 +194,7 @@ const TouchableWithoutFeedback = createReactClass({
testID: this.props.testID,
onLayout: this.props.onLayout,
hitSlop: this.props.hitSlop,
...child.props,
onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder,
onResponderTerminationRequest: this.touchableHandleResponderTerminationRequest,
onResponderGrant: this.touchableHandleResponderGrant,