Flow TouchableWithoutFeedback (#22479)

Summary:
Related to #22100

Enhance TouchableWithoutFeedback with press and target event types.
There are still work to do to update `UNSAFE_componentWillReceiveProps` and `touchableGetHitSlop` to make Flow not complain about `DeprecatedEdgeInsetsPropType` inexact type.
Pull Request resolved: https://github.com/facebook/react-native/pull/22479

Reviewed By: RSNara

Differential Revision: D13310764

Pulled By: TheSavior

fbshipit-source-id: 9002e542378491fb800c8e81c63f4fbe125b563c
This commit is contained in:
Thomas BARRAS
2018-12-04 17:03:53 -08:00
committed by Facebook Github Bot
parent 87b6533937
commit 7e4f92bc19
2 changed files with 21 additions and 17 deletions

View File

@@ -26,7 +26,7 @@ const {
DeprecatedAccessibilityTraits,
} = require('DeprecatedViewAccessibility');
import type {PressEvent} from 'CoreEventTypes';
import type {SyntheticEvent, LayoutEvent, PressEvent} from 'CoreEventTypes';
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
import type {
AccessibilityComponentType,
@@ -35,17 +35,21 @@ import type {
AccessibilityTraits,
} from 'ViewAccessibility';
type TargetEvent = SyntheticEvent<
$ReadOnly<{|
target: number,
|}>,
>;
type BlurEvent = TargetEvent;
type FocusEvent = TargetEvent;
const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
export type Props = $ReadOnly<{|
accessible?: ?boolean,
accessibilityComponentType?: ?AccessibilityComponentType,
accessibilityLabel?:
| null
| React$PropType$Primitive<any>
| string
| Array<any>
| any,
accessibilityLabel?: ?Stringish,
accessibilityHint?: ?Stringish,
accessibilityIgnoresInvertColors?: ?boolean,
accessibilityRole?: ?AccessibilityRole,
@@ -58,13 +62,13 @@ export type Props = $ReadOnly<{|
disabled?: ?boolean,
hitSlop?: ?EdgeInsetsProp,
nativeID?: ?string,
onBlur?: ?Function,
onFocus?: ?Function,
onLayout?: ?Function,
onLongPress?: ?Function,
onPress?: ?Function,
onPressIn?: ?Function,
onPressOut?: ?Function,
onBlur?: ?(e: BlurEvent) => void,
onFocus?: ?(e: FocusEvent) => void,
onLayout?: ?(event: LayoutEvent) => mixed,
onLongPress?: ?(event: PressEvent) => mixed,
onPress?: ?(event: PressEvent) => mixed,
onPressIn?: ?(event: PressEvent) => mixed,
onPressOut?: ?(event: PressEvent) => mixed,
pressRetentionOffset?: ?EdgeInsetsProp,
rejectResponderTermination?: ?boolean,
testID?: ?string,