Skip to content

Commit

Permalink
remove createReactClass from RNTester/js/ProgressViewIOSExample.js (f…
Browse files Browse the repository at this point in the history
…acebook#21611)

Summary:
Related to facebook#21581 .
Removed createReactClass from the RNTester/js/ProgressViewIOSExample.js

Test Plan
----------

  - [x] npm run prettier
  - [x] npm run flow-check-ios
  - [x] npm run flow-check-android
- [x] Run RNTester app, go to ProgressViewIOS component, everything works.

Release Notes
--------------

[GENERAL] [ENHANCEMENT] [RNTester/js/ProgressViewIOSExample.js] - remove createReactClass dependency
Pull Request resolved: facebook#21611

Reviewed By: TheSavior

Differential Revision: D10304566

Pulled By: RSNara

fbshipit-source-id: 98a9dc83a0517a2866c4174ae254e1a9d9785b87
  • Loading branch information
himanshusoni authored and facebook-github-bot committed Oct 10, 2018
1 parent 86bc7a0 commit e4064bd
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions RNTester/js/ProgressViewIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,42 @@

'use strict';

var React = require('react');
var createReactClass = require('create-react-class');
var ReactNative = require('react-native');
var {ProgressViewIOS, StyleSheet, View} = ReactNative;
const React = require('react');
const ReactNative = require('react-native');
const {ProgressViewIOS, StyleSheet, View} = ReactNative;

var ProgressViewExample = createReactClass({
displayName: 'ProgressViewExample',
_rafId: (null: ?AnimationFrameID),
type Props = {||};
type State = {|
progress: number,
|};

getInitialState() {
return {
progress: 0,
};
},
class ProgressViewExample extends React.Component<Props, State> {
_rafId: ?AnimationFrameID = null;

state = {
progress: 0,
};

componentDidMount() {
this.updateProgress();
},
}

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

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

getProgress(offset) {
getProgress = offset => {
var progress = this.state.progress + offset;
return Math.sin(progress % Math.PI) % 1;
},
};

render() {
return (
Expand Down Expand Up @@ -75,8 +76,8 @@ var ProgressViewExample = createReactClass({
/>
</View>
);
},
});
}
}

exports.displayName = (undefined: ?string);
exports.framework = 'React';
Expand Down

0 comments on commit e4064bd

Please sign in to comment.