mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 11:05:21 +00:00
RN: Switch ProgressBarAndroid
to React.forwardRef
Reviewed By: sahrens Differential Revision: D7904339 fbshipit-source-id: a4fe54acee7af12f1bc9b7c0d5e02a690f57ca0d
This commit is contained in:
parent
8799047dd0
commit
11cc7be821
@ -4,7 +4,9 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const ColorPropType = require('ColorPropType');
|
||||
@ -30,7 +32,9 @@ const indeterminateType = function(props, propName, componentName, ...rest) {
|
||||
const indeterminate = props[propName];
|
||||
const styleAttr = props.styleAttr;
|
||||
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',
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -38,8 +42,8 @@ const indeterminateType = function(props, propName, componentName, ...rest) {
|
||||
};
|
||||
|
||||
/**
|
||||
* React component that wraps the Android-only `ProgressBar`. This component is used to indicate
|
||||
* that the app is loading or there is some activity in the app.
|
||||
* React component that wraps the Android-only `ProgressBar`. This component is
|
||||
* used to indicate that the app is loading or there is activity in the app.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
@ -60,7 +64,7 @@ const indeterminateType = function(props, propName, componentName, ...rest) {
|
||||
* },
|
||||
* ```
|
||||
*/
|
||||
class ProgressBarAndroid extends ReactNative.NativeComponent {
|
||||
class ProgressBarAndroid extends React.Component {
|
||||
static propTypes = {
|
||||
...ViewPropTypes,
|
||||
|
||||
@ -106,7 +110,8 @@ class ProgressBarAndroid extends ReactNative.NativeComponent {
|
||||
};
|
||||
|
||||
render() {
|
||||
return <AndroidProgressBar {...this.props} />;
|
||||
const {forwardedRef, ...props} = this.props;
|
||||
return <AndroidProgressBar {...props} ref={forwardedRef} />;
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +122,9 @@ const AndroidProgressBar = requireNativeComponent(
|
||||
nativeOnly: {
|
||||
animating: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
module.exports = ProgressBarAndroid;
|
||||
module.exports = React.forwardRef((props, ref) => (
|
||||
<ProgressBarAndroid {...props} forwardedRef={ref} />
|
||||
));
|
||||
|
Loading…
x
Reference in New Issue
Block a user