Remove TimerMixin from TouchableWithoutFeedback (#21493)

Summary:
Related to #21485.
Removed `TimerMixin` from the `TouchableWithoutFeedback` component since it is currently not used.
Added tests cases for `TouchableWithoutFeedback` to check for any runtime issues.
Pull Request resolved: https://github.com/facebook/react-native/pull/21493

Differential Revision: D10219098

Pulled By: RSNara

fbshipit-source-id: d9517b2bd5b72b0450fa864f3556673ae3181552
This commit is contained in:
Thomas Carlson 2018-10-05 13:19:11 -07:00 committed by Facebook Github Bot
parent 8ceb1586ee
commit 6c20017152
2 changed files with 67 additions and 2 deletions

View File

@ -13,7 +13,6 @@
const DeprecatedEdgeInsetsPropType = require('DeprecatedEdgeInsetsPropType');
const React = require('React');
const PropTypes = require('prop-types');
const TimerMixin = require('react-timer-mixin');
const Touchable = require('Touchable');
const View = require('View');
@ -80,7 +79,7 @@ export type Props = $ReadOnly<{|
*/
const TouchableWithoutFeedback = ((createReactClass({
displayName: 'TouchableWithoutFeedback',
mixins: [TimerMixin, Touchable.Mixin],
mixins: [Touchable.Mixin],
propTypes: {
accessible: PropTypes.bool,

View File

@ -21,6 +21,7 @@ var {
TouchableOpacity,
Platform,
TouchableNativeFeedback,
TouchableWithoutFeedback,
View,
} = ReactNative;
@ -70,6 +71,12 @@ exports.examples = [
);
},
},
{
title: '<TouchableWithoutFeedback>',
render: function() {
return <TouchableWithoutFeedbackBox />;
},
},
{
title: 'TouchableNativeFeedback with Animated child',
description:
@ -150,6 +157,40 @@ exports.examples = [
},
];
class TouchableWithoutFeedbackBox extends React.Component<{}, $FlowFixMeState> {
state = {
timesPressed: 0,
};
textOnPress = () => {
this.setState({
timesPressed: this.state.timesPressed + 1,
});
};
render() {
var textLog = '';
if (this.state.timesPressed > 1) {
textLog = this.state.timesPressed + 'x TouchableWithoutFeedback onPress';
} else if (this.state.timesPressed > 0) {
textLog = 'TouchableWithoutFeedback onPress';
}
return (
<View>
<TouchableWithoutFeedback onPress={this.textOnPress}>
<View style={styles.wrapperCustom}>
<Text style={styles.text}>Tap Here For No Feedback!</Text>
</View>
</TouchableWithoutFeedback>
<View style={styles.logBox}>
<Text>{textLog}</Text>
</View>
</View>
);
}
}
class TextOnPressBox extends React.Component<{}, $FlowFixMeState> {
state = {
timesPressed: 0,
@ -360,6 +401,31 @@ class TouchableDisabled extends React.Component<{}> {
<Text style={styles.button}>Enabled TouchableHighlight</Text>
</TouchableHighlight>
<TouchableWithoutFeedback
onPress={() => console.log('TWOF has been clicked')}
disabled={true}>
<View style={styles.wrapperCustom}>
<Text
style={[
styles.button,
styles.nativeFeedbackButton,
styles.disabledButton,
]}>
Disabled TouchableWithoutFeedback
</Text>
</View>
</TouchableWithoutFeedback>
<TouchableWithoutFeedback
onPress={() => console.log('TWOF has been clicked')}
disabled={false}>
<View style={styles.wrapperCustom}>
<Text style={[styles.button, styles.nativeFeedbackButton]}>
Enabled TouchableWithoutFeedback
</Text>
</View>
</TouchableWithoutFeedback>
{Platform.OS === 'android' && (
<TouchableNativeFeedback
style={[styles.row, styles.block]}