mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 20:01:01 +08:00
Fix more forwardRef displayNames
Summary: See https://reactjs.org/docs/forwarding-refs.html#displaying-a-custom-name-in-devtools reapply of D8342904 Reviewed By: yungsters Differential Revision: D8465006 fbshipit-source-id: f196f39b9b1c9bbe16a845667ebbdb21953a5848
This commit is contained in:
committed by
Facebook Github Bot
parent
c5ce762697
commit
76eebce3c2
@@ -70,12 +70,10 @@ type Props = $ReadOnly<{|
|
||||
* See http://facebook.github.io/react-native/docs/activityindicator.html
|
||||
*/
|
||||
const ActivityIndicator = (
|
||||
props: $ReadOnly<{|
|
||||
...Props,
|
||||
forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>,
|
||||
|}>,
|
||||
props: Props,
|
||||
forwardedRef?: ?React.Ref<'RCTActivityIndicatorView'>,
|
||||
) => {
|
||||
const {onLayout, style, forwardedRef, ...restProps} = props;
|
||||
const {onLayout, style, ...restProps} = props;
|
||||
let sizeStyle;
|
||||
|
||||
switch (props.size) {
|
||||
@@ -99,16 +97,19 @@ const ActivityIndicator = (
|
||||
};
|
||||
|
||||
return (
|
||||
<View onLayout={onLayout} style={[styles.container, style]}>
|
||||
<View
|
||||
onLayout={onLayout}
|
||||
style={StyleSheet.compose(
|
||||
styles.container,
|
||||
style,
|
||||
)}>
|
||||
<RCTActivityIndicator {...nativeProps} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
||||
const ActivityIndicatorWithRef = React.forwardRef((props: Props, ref) => {
|
||||
return <ActivityIndicator {...props} forwardedRef={ref} />;
|
||||
});
|
||||
const ActivityIndicatorWithRef = React.forwardRef(ActivityIndicator);
|
||||
|
||||
ActivityIndicatorWithRef.defaultProps = {
|
||||
animating: true,
|
||||
@@ -116,7 +117,6 @@ ActivityIndicatorWithRef.defaultProps = {
|
||||
hidesWhenStopped: true,
|
||||
size: 'small',
|
||||
};
|
||||
ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
||||
Reference in New Issue
Block a user