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

[createReactClass] Remove createReactClass from ProgressBarAndroidExample #21874

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
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>,
>);
62 changes: 37 additions & 25 deletions RNTester/js/ProgressBarAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,51 @@

'use strict';

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

var MovingBar = createReactClass({
displayName: 'MovingBar',
_intervalID: (null: ?IntervalID),

getInitialState: function() {
return {
progress: 0,
};
},

componentDidMount: function() {
const ProgressBar = require('ProgressBarAndroid');
const React = require('React');
const RNTesterBlock = require('RNTesterBlock');
const RNTesterPage = require('RNTesterPage');

import type {ProgressBarAndroidProps} from 'ProgressBarAndroid';

type MovingBarProps = $ReadOnly<{|
...$Diff<
ProgressBarAndroidProps,
{
progress: ?number,
},
>,
indeterminate: false,
|}>;

type MovingBarState = {
progress: number,
};

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

state = {
progress: 0,
};

componentDidMount() {
this._intervalID = setInterval(() => {
var progress = (this.state.progress + 0.02) % 1;
this.setState({progress: progress});
const progress = (this.state.progress + 0.02) % 1;
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