Skip to content

Commit

Permalink
Remove createReactClass from ProgressBarAndroidExample (facebook#21874)
Browse files Browse the repository at this point in the history
Summary:
Related to facebook#21581

This PR was already opened here facebook#21600 but seems to be inactive.

Remove createReactClass from ProgressBarAndroidExample.

- `yarn run flow` && `yarn run flow-check-android` succeed.
- RNTester app ProgressBarAndroidExample on Android.

[GENERAL] [ENHANCEMENT] [ProgressBarAndroidExample.android.js] - rm createReactClass
Pull Request resolved: facebook#21874

Reviewed By: TheSavior

Differential Revision: D12827689

Pulled By: RSNara

fbshipit-source-id: 46c70ea67dddf5d928fe936a28ef4a0a929d127f
  • Loading branch information
exced authored and facebook-github-bot committed Nov 2, 2018
1 parent 23a4e48 commit f787e68
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {ViewProps} from 'ViewPropTypes';

const AndroidProgressBar = requireNativeComponent('AndroidProgressBar');

type Props = $ReadOnly<{|
export type ProgressBarAndroidProps = $ReadOnly<{|
...ViewProps,

/**
Expand Down Expand Up @@ -83,7 +83,7 @@ type Props = $ReadOnly<{|
* ```
*/
const ProgressBarAndroid = (
props: Props,
props: ProgressBarAndroidProps,
forwardedRef: ?React.Ref<'AndroidProgressBar'>,
) => {
return <AndroidProgressBar {...props} ref={forwardedRef} />;
Expand All @@ -98,4 +98,6 @@ ProgressBarAndroidToExport.defaultProps = {
animating: true,
};

module.exports = (ProgressBarAndroidToExport: Class<NativeComponent<Props>>);
module.exports = (ProgressBarAndroidToExport: Class<
NativeComponent<ProgressBarAndroidProps>,
>);
46 changes: 29 additions & 17 deletions RNTester/js/ProgressBarAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,49 @@

const ProgressBar = require('ProgressBarAndroid');
const React = require('React');
const createReactClass = require('create-react-class');
const RNTesterBlock = require('RNTesterBlock');
const RNTesterPage = require('RNTesterPage');

const MovingBar = createReactClass({
displayName: 'MovingBar',
_intervalID: (null: ?IntervalID),
import type {ProgressBarAndroidProps} from 'ProgressBarAndroid';

getInitialState: function() {
return {
progress: 0,
};
},
type MovingBarProps = $ReadOnly<{|
...$Diff<
ProgressBarAndroidProps,
{
progress: ?number,
},
>,
indeterminate: false,
|}>;

componentDidMount: function() {
type MovingBarState = {
progress: number,
};

class MovingBar extends React.Component<MovingBarProps, MovingBarState> {
_intervalID: ?IntervalID = null;

state = {
progress: 0,
};

componentDidMount() {
this._intervalID = setInterval(() => {
const progress = (this.state.progress + 0.02) % 1;
this.setState({progress: progress});
this.setState({progress});
}, 50);
},
}

componentWillUnmount: function() {
componentWillUnmount() {
if (this._intervalID != null) {
clearInterval(this._intervalID);
}
},
}

render: function() {
render() {
return <ProgressBar progress={this.state.progress} {...this.props} />;
},
});
}
}

class ProgressBarAndroidExample extends React.Component<{}> {
static title = '<ProgressBarAndroid>';
Expand Down

0 comments on commit f787e68

Please sign in to comment.