Skip to content

Commit de416e7

Browse files
gvarandasfacebook-github-bot
authored andcommitted
Removing TimerMixin on SwipeableRow (facebook#21499)
Summary: Related to facebook#21485. Removed TimerMixin from the SwipeableRow component since it is currently not used. Added a test case for `SwipeableRow` animation in the `SwipeableListViewSimpleExample`, by adding the `bounceFirstRowOnMount` prop, to check for any runtime issues with the setTimeout method. - [x] `npm run prettier` - [x] `npm run flow-check-ios` - [x] `npm run flow-check-android` - [x] runtime tests using `SwipeableFlatListExample` on Android and iOS - [x] runtime tests using `SwipeableListViewSimpleExample` on Android and iOS **RNTester steps** - [x] Run RNTester. - [x] Navigate to `SwipeableFlatListExample` and check if the `_animateBounceBack` animation executes when the `shouldBounceOnMount` props is passed. - [x] Swipe the row and check if the events ran correctly - [x] Navigate to `SwipeableListViewSimpleExample` and check if the `_animateBounceBack` animation executes when the `shouldBounceOnMount` props is passed. - [x] Swipe the row and check if the events ran correctly [GENERAL] [ENHANCEMENT] [Libraries/Experimental/SwipeableRow/SwipeableRow.js] - remove TimerMixin dependency [GENERAL] [ENHANCEMENT] [RNTester/js/SwipeableListViewSimpleExample.js] - Add bounceFirstRowOnMount to guarantee the SwipeableRow correct behavior. Pull Request resolved: facebook#21499 Reviewed By: TheSavior Differential Revision: D10218361 Pulled By: RSNara fbshipit-source-id: c8e6d5ced4c1237e48bb4c43592016684b2c6360
1 parent b3f4872 commit de416e7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Libraries/Experimental/SwipeableRow/SwipeableRow.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ const PanResponder = require('PanResponder');
1616
const React = require('React');
1717
const PropTypes = require('prop-types');
1818
const StyleSheet = require('StyleSheet');
19-
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
20-
* found when Flow v0.54 was deployed. To see the error delete this comment and
21-
* run Flow. */
22-
const TimerMixin = require('react-timer-mixin');
2319
const View = require('View');
2420

2521
const createReactClass = require('create-react-class');
@@ -85,8 +81,7 @@ const SwipeableRow = createReactClass({
8581
displayName: 'SwipeableRow',
8682
_panResponder: {},
8783
_previousLeft: CLOSED_LEFT_POSITION,
88-
89-
mixins: [TimerMixin],
84+
_timeoutID: (null: ?TimeoutID),
9085

9186
propTypes: {
9287
children: PropTypes.any,
@@ -157,7 +152,7 @@ const SwipeableRow = createReactClass({
157152
* Do the on mount bounce after a delay because if we animate when other
158153
* components are loading, the animation will be laggy
159154
*/
160-
this.setTimeout(() => {
155+
this._timeoutID = setTimeout(() => {
161156
this._animateBounceBack(ON_MOUNT_BOUNCE_DURATION);
162157
}, ON_MOUNT_BOUNCE_DELAY);
163158
}
@@ -173,6 +168,12 @@ const SwipeableRow = createReactClass({
173168
}
174169
},
175170

171+
componentWillUnmount() {
172+
if (this._timeoutID != null) {
173+
clearTimeout(this._timeoutID);
174+
}
175+
},
176+
176177
render(): React.Element<any> {
177178
// The view hidden behind the main view
178179
let slideOutView;

0 commit comments

Comments
 (0)