Skip to content

Commit a7f9583

Browse files
himanshusonifacebook-github-bot
authored andcommitted
remove createReactClass from RNTester/js/ProgressViewIOSExample.js (#21611)
Summary: Related to #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: #21611 Reviewed By: TheSavior Differential Revision: D10304566 Pulled By: RSNara fbshipit-source-id: 98a9dc83a0517a2866c4174ae254e1a9d9785b87
1 parent bf47589 commit a7f9583

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

RNTester/js/ProgressViewIOSExample.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,42 @@
1010

1111
'use strict';
1212

13-
var React = require('react');
14-
var createReactClass = require('create-react-class');
15-
var ReactNative = require('react-native');
16-
var {ProgressViewIOS, StyleSheet, View} = ReactNative;
13+
const React = require('react');
14+
const ReactNative = require('react-native');
15+
const {ProgressViewIOS, StyleSheet, View} = ReactNative;
1716

18-
var ProgressViewExample = createReactClass({
19-
displayName: 'ProgressViewExample',
20-
_rafId: (null: ?AnimationFrameID),
17+
type Props = {||};
18+
type State = {|
19+
progress: number,
20+
|};
2121

22-
getInitialState() {
23-
return {
24-
progress: 0,
25-
};
26-
},
22+
class ProgressViewExample extends React.Component<Props, State> {
23+
_rafId: ?AnimationFrameID = null;
24+
25+
state = {
26+
progress: 0,
27+
};
2728

2829
componentDidMount() {
2930
this.updateProgress();
30-
},
31+
}
3132

3233
componentWillUnmount() {
3334
if (this._rafId != null) {
3435
cancelAnimationFrame(this._rafId);
3536
}
36-
},
37+
}
3738

38-
updateProgress() {
39+
updateProgress = () => {
3940
var progress = this.state.progress + 0.01;
4041
this.setState({progress});
4142
this._rafId = requestAnimationFrame(() => this.updateProgress());
42-
},
43+
};
4344

44-
getProgress(offset) {
45+
getProgress = offset => {
4546
var progress = this.state.progress + offset;
4647
return Math.sin(progress % Math.PI) % 1;
47-
},
48+
};
4849

4950
render() {
5051
return (
@@ -75,8 +76,8 @@ var ProgressViewExample = createReactClass({
7576
/>
7677
</View>
7778
);
78-
},
79-
});
79+
}
80+
}
8081

8182
exports.displayName = (undefined: ?string);
8283
exports.framework = 'React';

0 commit comments

Comments
 (0)