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

[TS migration] Migrate 'FullscreenLoadingIndicator.js' component to TypeScript #29988

33 changes: 0 additions & 33 deletions src/components/FullscreenLoadingIndicator.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/components/FullscreenLoadingIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import {ActivityIndicator, StyleProp, StyleSheet, View, ViewStyle} from 'react-native';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';

type FullScreenLoadingIndicatorProps = {
style?: StyleProp<ViewStyle>;
};

function FullScreenLoadingIndicator({style}: FullScreenLoadingIndicatorProps) {
return (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading, style]}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, so passing a style array here just works? Was the old logic unnecessary?

const additionalStyles = _.isArray(props.style) ? props.style : [props.style];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaciejSWM Let's ensure this change was intended

Copy link
Contributor Author

@MaciejSWM MaciejSWM Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out it works just fine. It's not only correct Typescript, but it also works when I test it with all the combinations of style:
http://localhost:8082/settings/profile/display-name
In DisplayNamePage.js (I renamed it to .tsx to highlight any errors, but none showed up):

{!props.isLoadingApp ? (
  <>
      <View style={{ height: '20%' }}>
          {/* No style */}
          <FullScreenLoadingIndicator />
      </View>
      <View style={{ height: '20%' }}>
          {/* Empty array style */}
          <FullScreenLoadingIndicator style={[]} />
      </View>
      <View style={{ height: '20%' }}>
          {/* Just one style */}
          <FullScreenLoadingIndicator style={styles.backgroundPurple} />
      </View>
      <View style={{ height: '20%' }}>
          {/* Array of styles */}
          <FullScreenLoadingIndicator style={[styles.backgroundPurple, styles.backgroundGold]} />
      </View>
  </>
) : (
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for verifying this!

<ActivityIndicator
color={themeColors.spinner}
size="large"
/>
</View>
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always define displayName:

Suggested change
FullScreenLoadingIndicator.displayName = 'FullScreenLoadingIndicator';

FullScreenLoadingIndicator.displayName = 'FullScreenLoadingIndicator';

export default FullScreenLoadingIndicator;
Loading