Skip to content

Commit 9499480

Browse files
gvarandasfacebook-github-bot
authored andcommitted
Removing TimerMixin on ProgressViewIOSExample (#21500)
Summary: Related to #21485. Removed TimerMixin from the `RNTester/js/ProgressViewIOSExample.js` screen since it is currently not used. - [x] `npm run prettier` - [x] `npm run flow-check-ios` - [x] `npm run flow-check-android` - [x] runtime tests using `ProgressViewIOSExample` on Android and iOS **RNTester steps** - [x] Run RNTester. - [x] Navigate to `ProgressViewIOSExample` and check if the animations are executed correctly and without lag. [GENERAL] [ENHANCEMENT] [RNTester/js/ProgressViewIOSExample.js] - remove TimerMixin dependency Pull Request resolved: facebook/react-native#21500 Reviewed By: TheSavior Differential Revision: D10218366 Pulled By: RSNara fbshipit-source-id: b44a0bbb50f6b0e85f406904131804eace941335
1 parent ad4e0b8 commit 9499480

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

js/ProgressViewIOSExample.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ var React = require('react');
1414
var createReactClass = require('create-react-class');
1515
var ReactNative = require('react-native');
1616
var {ProgressViewIOS, StyleSheet, View} = ReactNative;
17-
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
18-
* found when Flow v0.54 was deployed. To see the error delete this comment and
19-
* run Flow. */
20-
var TimerMixin = require('react-timer-mixin');
2117

2218
var ProgressViewExample = createReactClass({
2319
displayName: 'ProgressViewExample',
24-
mixins: [TimerMixin],
20+
_rafId: (null: ?AnimationFrameID),
2521

2622
getInitialState() {
2723
return {
@@ -33,10 +29,16 @@ var ProgressViewExample = createReactClass({
3329
this.updateProgress();
3430
},
3531

32+
componentWillUnmount() {
33+
if (this._rafId != null) {
34+
cancelAnimationFrame(this._rafId);
35+
}
36+
},
37+
3638
updateProgress() {
3739
var progress = this.state.progress + 0.01;
3840
this.setState({progress});
39-
this.requestAnimationFrame(() => this.updateProgress());
41+
this._rafId = requestAnimationFrame(() => this.updateProgress());
4042
},
4143

4244
getProgress(offset) {

0 commit comments

Comments
 (0)