mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 21:53:30 +00:00
Fixed runtime error with ProgressBarAndroid
Reviewed By: yungsters Differential Revision: D5857305 fbshipit-source-id: 2fc20a848fa4dce5c1ac3fb7e986536618e25548
This commit is contained in:
parent
9e373529f3
commit
ccddbf82d7
@ -10,16 +10,14 @@
|
|||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
const ActivityIndicator = require('ActivityIndicator');
|
||||||
var React = require('React');
|
const ColorPropType = require('ColorPropType');
|
||||||
var PropTypes = require('prop-types');
|
const PropTypes = require('prop-types');
|
||||||
var ViewPropTypes = require('ViewPropTypes');
|
const React = require('React');
|
||||||
var ColorPropType = require('ColorPropType');
|
const ReactNative = require('ReactNative');
|
||||||
|
const ViewPropTypes = require('ViewPropTypes');
|
||||||
|
|
||||||
var createReactClass = require('create-react-class');
|
const STYLE_ATTRIBUTES = [
|
||||||
var requireNativeComponent = require('requireNativeComponent');
|
|
||||||
|
|
||||||
var STYLE_ATTRIBUTES = [
|
|
||||||
'Horizontal',
|
'Horizontal',
|
||||||
'Normal',
|
'Normal',
|
||||||
'Small',
|
'Small',
|
||||||
@ -29,10 +27,10 @@ var STYLE_ATTRIBUTES = [
|
|||||||
'LargeInverse',
|
'LargeInverse',
|
||||||
];
|
];
|
||||||
|
|
||||||
var indeterminateType = function(props, propName, componentName, ...rest) {
|
const indeterminateType = function(props, propName, componentName, ...rest) {
|
||||||
var checker = function() {
|
const checker = function() {
|
||||||
var indeterminate = props[propName];
|
const indeterminate = props[propName];
|
||||||
var styleAttr = props.styleAttr;
|
const styleAttr = props.styleAttr;
|
||||||
if (!indeterminate && styleAttr !== 'Horizontal') {
|
if (!indeterminate && styleAttr !== 'Horizontal') {
|
||||||
return new Error('indeterminate=false is only valid for styleAttr=Horizontal');
|
return new Error('indeterminate=false is only valid for styleAttr=Horizontal');
|
||||||
}
|
}
|
||||||
@ -64,10 +62,10 @@ var indeterminateType = function(props, propName, componentName, ...rest) {
|
|||||||
* },
|
* },
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
var ProgressBarAndroid = createReactClass({
|
class ProgressBarAndroid extends ReactNative.NativeComponent {
|
||||||
displayName: 'ProgressBarAndroid',
|
static propTypes = {
|
||||||
propTypes: {
|
|
||||||
...ViewPropTypes,
|
...ViewPropTypes,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Style of the ProgressBar. One of:
|
* Style of the ProgressBar. One of:
|
||||||
*
|
*
|
||||||
@ -97,35 +95,25 @@ var ProgressBarAndroid = createReactClass({
|
|||||||
* Used to locate this view in end-to-end tests.
|
* Used to locate this view in end-to-end tests.
|
||||||
*/
|
*/
|
||||||
testID: PropTypes.string,
|
testID: PropTypes.string,
|
||||||
},
|
};
|
||||||
|
|
||||||
getDefaultProps: function() {
|
static defaultProps = {
|
||||||
return {
|
|
||||||
styleAttr: 'Normal',
|
styleAttr: 'Normal',
|
||||||
indeterminate: true
|
indeterminate: true
|
||||||
};
|
};
|
||||||
},
|
|
||||||
|
|
||||||
mixins: [NativeMethodsMixin],
|
componentDidMount() {
|
||||||
|
|
||||||
componentDidMount: function() {
|
|
||||||
if (this.props.indeterminate && this.props.styleAttr !== 'Horizontal') {
|
if (this.props.indeterminate && this.props.styleAttr !== 'Horizontal') {
|
||||||
console.warn(
|
console.warn(
|
||||||
'Circular indeterminate `ProgressBarAndroid`' +
|
'Circular indeterminate `ProgressBarAndroid`' +
|
||||||
'is deprecated. Use `ActivityIndicator` instead.'
|
'is deprecated. Use `ActivityIndicator` instead.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
render: function() {
|
render() {
|
||||||
return <AndroidProgressBar {...this.props} />;
|
return <ActivityIndicator {...this.props} animating={true} />;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
var AndroidProgressBar = requireNativeComponent(
|
|
||||||
'AndroidProgressBar',
|
|
||||||
ProgressBarAndroid,
|
|
||||||
{nativeOnly: {animating: true}},
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = ProgressBarAndroid;
|
module.exports = ProgressBarAndroid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user