Skip to content

Commit 732aad9

Browse files
authored
Merge pull request #30774 from JKobrynski/migrateReportActionSkeletonViewToTypeScript
[TS Migration] Migrate ReportActionsSkeletonView and SkeletonViewContentLoader directories to TypeScript
2 parents feae468 + 5bd34f6 commit 732aad9

File tree

7 files changed

+39
-34
lines changed

7 files changed

+39
-34
lines changed

src/components/ReportActionsSkeletonView/SkeletonViewLines.js src/components/ReportActionsSkeletonView/SkeletonViewLines.tsx

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import {Circle, Rect} from 'react-native-svg';
43
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
54
import styles from '@styles/styles';
65
import themeColors from '@styles/themes/default';
76
import CONST from '@src/CONST';
87

9-
const propTypes = {
8+
type SkeletonViewLinesProps = {
109
/** Number of rows to show in Skeleton UI block */
11-
numberOfRows: PropTypes.number.isRequired,
12-
shouldAnimate: PropTypes.bool,
10+
numberOfRows: 1 | 2 | 3;
11+
shouldAnimate?: boolean;
1312
};
1413

15-
const defaultTypes = {
16-
shouldAnimate: true,
17-
};
18-
19-
function SkeletonViewLines(props) {
14+
function SkeletonViewLines({numberOfRows, shouldAnimate = true}: SkeletonViewLinesProps) {
2015
return (
2116
<SkeletonViewContentLoader
22-
animate={props.shouldAnimate}
23-
height={CONST.CHAT_SKELETON_VIEW.HEIGHT_FOR_ROW_COUNT[props.numberOfRows]}
17+
animate={shouldAnimate}
18+
height={CONST.CHAT_SKELETON_VIEW.HEIGHT_FOR_ROW_COUNT[numberOfRows]}
2419
backgroundColor={themeColors.skeletonLHNIn}
2520
foregroundColor={themeColors.skeletonLHNOut}
2621
style={styles.mr5}
@@ -42,15 +37,15 @@ function SkeletonViewLines(props) {
4237
width="100%"
4338
height="8"
4439
/>
45-
{props.numberOfRows > 1 && (
40+
{numberOfRows > 1 && (
4641
<Rect
4742
x="72"
4843
y="51"
4944
width="50%"
5045
height="8"
5146
/>
5247
)}
53-
{props.numberOfRows > 2 && (
48+
{numberOfRows > 2 && (
5449
<Rect
5550
x="72"
5651
y="71"
@@ -63,6 +58,4 @@ function SkeletonViewLines(props) {
6358
}
6459

6560
SkeletonViewLines.displayName = 'SkeletonViewLines';
66-
SkeletonViewLines.propTypes = propTypes;
67-
SkeletonViewLines.defaultProps = defaultTypes;
6861
export default SkeletonViewLines;

src/components/ReportActionsSkeletonView/index.js src/components/ReportActionsSkeletonView/index.tsx

+5-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
1-
import PropTypes from 'prop-types';
21
import React from 'react';
32
import {Dimensions, View} from 'react-native';
43
import CONST from '@src/CONST';
54
import SkeletonViewLines from './SkeletonViewLines';
65

7-
const propTypes = {
6+
type ReportActionsSkeletonViewProps = {
87
/** Whether to animate the skeleton view */
9-
shouldAnimate: PropTypes.bool,
8+
shouldAnimate?: boolean;
109

1110
/** Number of possible visible content items */
12-
possibleVisibleContentItems: PropTypes.number,
11+
possibleVisibleContentItems?: number;
1312
};
1413

15-
const defaultProps = {
16-
shouldAnimate: true,
17-
possibleVisibleContentItems: 0,
18-
};
19-
20-
function ReportActionsSkeletonView({shouldAnimate, possibleVisibleContentItems}) {
14+
function ReportActionsSkeletonView({shouldAnimate = true, possibleVisibleContentItems = 0}: ReportActionsSkeletonViewProps) {
2115
const contentItems = possibleVisibleContentItems || Math.ceil(Dimensions.get('window').height / CONST.CHAT_SKELETON_VIEW.AVERAGE_ROW_HEIGHT);
22-
const skeletonViewLines = [];
16+
const skeletonViewLines: React.ReactNode[] = [];
2317
for (let index = 0; index < contentItems; index++) {
2418
const iconIndex = (index + 1) % 4;
2519
switch (iconIndex) {
@@ -55,6 +49,4 @@ function ReportActionsSkeletonView({shouldAnimate, possibleVisibleContentItems})
5549
}
5650

5751
ReportActionsSkeletonView.displayName = 'ReportActionsSkeletonView';
58-
ReportActionsSkeletonView.propTypes = propTypes;
59-
ReportActionsSkeletonView.defaultProps = defaultProps;
6052
export default ReportActionsSkeletonView;

src/components/SkeletonViewContentLoader/index.js

-3
This file was deleted.

src/components/SkeletonViewContentLoader/index.native.js

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import SkeletonViewContentLoader from 'react-content-loader/native';
3+
import SkeletonViewContentLoaderProps from './types';
4+
5+
function ContentLoader(props: SkeletonViewContentLoaderProps) {
6+
// eslint-disable-next-line react/jsx-props-no-spreading
7+
return <SkeletonViewContentLoader {...props} />;
8+
}
9+
10+
export default ContentLoader;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import SkeletonViewContentLoader from 'react-content-loader';
3+
import SkeletonViewContentLoaderProps from './types';
4+
5+
function ContentLoader(props: SkeletonViewContentLoaderProps) {
6+
// eslint-disable-next-line react/jsx-props-no-spreading
7+
return <SkeletonViewContentLoader {...props} />;
8+
}
9+
10+
export default ContentLoader;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import {IContentLoaderProps} from 'react-content-loader';
2+
import {IContentLoaderProps as NativeIContentLoaderProps} from 'react-content-loader/native';
3+
4+
type SkeletonViewContentLoaderProps = IContentLoaderProps & NativeIContentLoaderProps;
5+
6+
export default SkeletonViewContentLoaderProps;

0 commit comments

Comments
 (0)