Skip to content

Commit

Permalink
Removing TimerMixin on SwipeableRow (facebook#21499)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gvarandas authored and facebook-github-bot committed Oct 8, 2018
1 parent 751ba1b commit e91de84
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Libraries/Experimental/SwipeableRow/SwipeableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const PanResponder = require('PanResponder');
const React = require('React');
const PropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const TimerMixin = require('react-timer-mixin');
const View = require('View');

const createReactClass = require('create-react-class');
Expand Down Expand Up @@ -85,8 +81,7 @@ const SwipeableRow = createReactClass({
displayName: 'SwipeableRow',
_panResponder: {},
_previousLeft: CLOSED_LEFT_POSITION,

mixins: [TimerMixin],
_timeoutID: (null: ?TimeoutID),

propTypes: {
children: PropTypes.any,
Expand Down Expand Up @@ -157,7 +152,7 @@ const SwipeableRow = createReactClass({
* Do the on mount bounce after a delay because if we animate when other
* components are loading, the animation will be laggy
*/
this.setTimeout(() => {
this._timeoutID = setTimeout(() => {
this._animateBounceBack(ON_MOUNT_BOUNCE_DURATION);
}, ON_MOUNT_BOUNCE_DELAY);
}
Expand All @@ -173,6 +168,12 @@ const SwipeableRow = createReactClass({
}
},

componentWillUnmount() {
if (this._timeoutID != null) {
clearTimeout(this._timeoutID);
}
},

render(): React.Element<any> {
// The view hidden behind the main view
let slideOutView;
Expand Down

0 comments on commit e91de84

Please sign in to comment.