Skip to content

Commit 4e36657

Browse files
excedfacebook-github-bot
authored andcommitted
Flow strict TouchableBounce (facebook#22197)
Summary: Related to facebook#22100 Enhance TouchableBounce with press event types, callback and hitslop types. There is still some work to do in order to turn flow to strict mode. (requireNativeComponent and render function) - All flow tests succeed. [GENERAL] [ENHANCEMENT] [TouchableBounce.js] - Flow types Pull Request resolved: facebook#22197 Reviewed By: TheSavior Differential Revision: D13032452 Pulled By: RSNara fbshipit-source-id: b21140722ce924698aa15323602e2e3fc663dbb6
1 parent 12e37f5 commit 4e36657

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Libraries/Components/Touchable/TouchableBounce.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const createReactClass = require('create-react-class');
2323
import type {EdgeInsetsProp} from 'EdgeInsetsPropType';
2424
import type {ViewStyleProp} from 'StyleSheet';
2525
import type {Props as TouchableWithoutFeedbackProps} from 'TouchableWithoutFeedback';
26-
27-
type Event = Object;
26+
import type {PressEvent} from 'CoreEventTypes';
2827

2928
type State = {
3029
animationID: ?number,
@@ -36,8 +35,8 @@ const PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30};
3635
type Props = $ReadOnly<{|
3736
...TouchableWithoutFeedbackProps,
3837

39-
onPressWithCompletion?: ?Function,
40-
onPressAnimationComplete?: ?Function,
38+
onPressWithCompletion?: ?(fn: () => void) => void,
39+
onPressAnimationComplete?: ?() => void,
4140
pressRetentionOffset?: ?EdgeInsetsProp,
4241
releaseVelocity?: ?number,
4342
releaseBounciness?: ?number,
@@ -95,7 +94,7 @@ const TouchableBounce = ((createReactClass({
9594
value: number,
9695
velocity: number,
9796
bounciness: number,
98-
callback?: ?Function,
97+
callback?: ?() => void,
9998
) {
10099
Animated.spring(this.state.scale, {
101100
toValue: value,
@@ -116,17 +115,17 @@ const TouchableBounce = ((createReactClass({
116115
* `Touchable.Mixin` self callbacks. The mixin will invoke these if they are
117116
* defined on your component.
118117
*/
119-
touchableHandleActivePressIn: function(e: Event) {
118+
touchableHandleActivePressIn: function(e: PressEvent) {
120119
this.bounceTo(0.93, 0.1, 0);
121120
this.props.onPressIn && this.props.onPressIn(e);
122121
},
123122

124-
touchableHandleActivePressOut: function(e: Event) {
123+
touchableHandleActivePressOut: function(e: PressEvent) {
125124
this.bounceTo(1, 0.4, 0);
126125
this.props.onPressOut && this.props.onPressOut(e);
127126
},
128127

129-
touchableHandlePress: function(e: Event) {
128+
touchableHandlePress: function(e: PressEvent) {
130129
const onPressWithCompletion = this.props.onPressWithCompletion;
131130
if (onPressWithCompletion) {
132131
onPressWithCompletion(() => {
@@ -154,7 +153,7 @@ const TouchableBounce = ((createReactClass({
154153
return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET;
155154
},
156155

157-
touchableGetHitSlop: function(): ?Object {
156+
touchableGetHitSlop: function(): ?EdgeInsetsProp {
158157
return this.props.hitSlop;
159158
},
160159

0 commit comments

Comments
 (0)