diff --git a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx index 5e43b8c07f..74e07b7933 100644 --- a/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx +++ b/packages/react-native-gesture-handler/src/components/touchables/GenericTouchable.tsx @@ -31,9 +31,7 @@ interface InternalProps { onStateChange?: (oldState: TouchableState, newState: TouchableState) => void; } -// TODO: maybe can be better -// TODO: all clearTimeout have ! added, maybe they shouldn't ? -type Timeout = ReturnType | null | undefined; +type Timeout = ReturnType | undefined; /** * GenericTouchable is not intented to be used as it is. @@ -70,7 +68,7 @@ export default class GenericTouchable extends Component< if (this.props.delayPressIn) { this.pressInTimeout = setTimeout(() => { this.moveToState(TOUCHABLE_STATE.BEGAN); - this.pressInTimeout = null; + this.pressInTimeout = undefined; }, this.props.delayPressIn); } else { this.moveToState(TOUCHABLE_STATE.BEGAN); @@ -89,7 +87,7 @@ export default class GenericTouchable extends Component< this.pressOutTimeout || setTimeout(() => { this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE); - this.pressOutTimeout = null; + this.pressOutTimeout = undefined; }, this.props.delayPressOut); } else { this.moveToState(TOUCHABLE_STATE.MOVED_OUTSIDE); @@ -105,7 +103,7 @@ export default class GenericTouchable extends Component< this.moveToState(TOUCHABLE_STATE.BEGAN); } this.moveToState(TOUCHABLE_STATE.UNDETERMINED); - this.pressOutTimeout = null; + this.pressOutTimeout = undefined; }, this.props.delayPressOut); } else { if (this.STATE === TOUCHABLE_STATE.UNDETERMINED) { @@ -125,9 +123,9 @@ export default class GenericTouchable extends Component< clearTimeout(this.pressInTimeout); clearTimeout(this.pressOutTimeout); clearTimeout(this.longPressTimeout); - this.pressOutTimeout = null; - this.longPressTimeout = null; - this.pressInTimeout = null; + this.pressOutTimeout = undefined; + this.longPressTimeout = undefined; + this.pressInTimeout = undefined; } // All states' transitions are defined here. @@ -189,7 +187,7 @@ export default class GenericTouchable extends Component< const shouldCallOnPress = !this.longPressDetected && this.STATE !== TOUCHABLE_STATE.MOVED_OUTSIDE && - this.pressOutTimeout === null; + this.pressOutTimeout === undefined; this.handleGoToUndetermined(); if (shouldCallOnPress) { // Calls only inside component whether no long press was called previously @@ -219,7 +217,7 @@ export default class GenericTouchable extends Component< onMoveOut() { // Long press should no longer be detected clearTimeout(this.longPressTimeout); - this.longPressTimeout = null; + this.longPressTimeout = undefined; if (this.STATE === TOUCHABLE_STATE.BEGAN) { this.handleMoveOutside(); }