Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TimerMixin] Removing TimerMixin on ProgressViewIOSExample #21500

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions RNTester/js/ProgressViewIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ var {ProgressViewIOS, StyleSheet, View} = ReactNative;
/* $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. */
var TimerMixin = require('react-timer-mixin');

var ProgressViewExample = createReactClass({
displayName: 'ProgressViewExample',
mixins: [TimerMixin],
_rafId: (null: ?AnimationFrameID),

getInitialState() {
return {
Expand All @@ -33,10 +32,16 @@ var ProgressViewExample = createReactClass({
this.updateProgress();
},

componentWillUnmount() {
if (this._rafId != null) {
cancelAnimationFrame(this._rafId);
}
},

updateProgress() {
var progress = this.state.progress + 0.01;
this.setState({progress});
this.requestAnimationFrame(() => this.updateProgress());
this._rafId = requestAnimationFrame(() => this.updateProgress());
},

getProgress(offset) {
Expand Down