Skip to content

Commit 2818b7e

Browse files
authored
Remove some Skeleton props (#2482)
1 parent a8027eb commit 2818b7e

File tree

1 file changed

+17
-77
lines changed

1 file changed

+17
-77
lines changed

src/components/skeletonView/index.tsx

Lines changed: 17 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ export interface SkeletonViewProps extends AccessibilityProps, AlignmentModifier
6767
* Custom value of any type to pass on to SkeletonView and receive back in the renderContent callback.
6868
*/
6969
customValue?: any;
70-
/**
71-
* @deprecated
72-
* - Please use customValue instead.
73-
* - Custom value of any type to pass on to SkeletonView and receive back in the renderContent callback.
74-
*/
75-
contentData?: any;
7670
/**
7771
* The type of the skeleton view.
7872
* Types: LIST_ITEM and TEXT_CONTENT (using SkeletonView.templates.###)
@@ -94,32 +88,6 @@ export interface SkeletonViewProps extends AccessibilityProps, AlignmentModifier
9488
* This is needed because the `key` prop is not accessible.
9589
*/
9690
timesKey?: string;
97-
/**
98-
* @deprecated
99-
* - Pass via listProps instead.
100-
* - The size of the skeleton view.
101-
* - Types: SMALL and LARGE (using SkeletonView.sizes.###)
102-
*/
103-
size?: Size;
104-
/**
105-
* @deprecated
106-
* - Pass via listProps instead.
107-
* - Add content to the skeleton.
108-
* - Types: AVATAR and THUMBNAIL (using SkeletonView.contentTypes.###)
109-
*/
110-
contentType?: ContentType;
111-
/**
112-
* @deprecated
113-
* - Pass via listProps instead.
114-
* - Whether to hide the list item template separator
115-
*/
116-
hideSeparator?: boolean;
117-
/**
118-
* @deprecated
119-
* - Pass via listProps instead.
120-
* - Whether to show the last list item template separator
121-
*/
122-
showLastSeparator?: boolean;
12391
/**
12492
* The height of the skeleton view
12593
*/
@@ -266,41 +234,22 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
266234
};
267235
};
268236

269-
get size() {
270-
const {listProps, size} = this.props;
271-
return listProps?.size || size;
272-
}
273-
274237
get contentSize() {
275-
return this.size === Size.LARGE ? 48 : 40;
276-
}
277-
278-
get contentType() {
279-
const {listProps, contentType} = this.props;
280-
return listProps?.contentType || contentType;
281-
}
282-
283-
get hideSeparator() {
284-
const {listProps, hideSeparator} = this.props;
285-
return listProps?.hideSeparator || hideSeparator;
286-
}
287-
288-
get showLastSeparator() {
289-
const {listProps, showLastSeparator} = this.props;
290-
return listProps?.showLastSeparator || showLastSeparator;
238+
const {listProps} = this.props;
239+
return listProps?.size === Size.LARGE ? 48 : 40;
291240
}
292241

293242
renderListItemLeftContent = () => {
294-
const contentType = this.contentType;
243+
const {listProps} = this.props;
244+
const contentType = listProps?.contentType;
295245
if (contentType) {
296-
const contentSize = this.contentSize;
297246
const circleOverride = contentType === ContentType.AVATAR;
298-
const style = {marginRight: this.size === Size.LARGE ? 16 : 14};
247+
const style = {marginRight: listProps?.size === Size.LARGE ? 16 : 14};
299248
return (
300249
<ShimmerPlaceholder
301250
{...this.getDefaultSkeletonProps({circleOverride, style})}
302-
width={contentSize}
303-
height={contentSize}
251+
width={this.contentSize}
252+
height={this.contentSize}
304253
/>
305254
);
306255
}
@@ -319,15 +268,13 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
319268

320269
renderListItemContentStrips = () => {
321270
const {listProps} = this.props;
322-
const contentType = this.contentType;
323-
const size = this.size;
324-
const hideSeparator = this.hideSeparator;
325-
const customLengths = contentType === ContentType.AVATAR ? [undefined, 50] : undefined;
271+
const size = listProps?.size;
272+
const customLengths = listProps?.contentType === ContentType.AVATAR ? [undefined, 50] : undefined;
326273
const height = size === Size.LARGE ? 95 : 75;
327274
const lengths = _.merge([90, 180, 160], customLengths);
328275
const topMargins = [0, size === Size.LARGE ? 16 : 8, 8];
329276
return (
330-
<View flex height={height} centerV style={!hideSeparator && Dividers.d10} row>
277+
<View flex height={height} centerV style={!listProps?.hideSeparator && Dividers.d10} row>
331278
<View>
332279
{this.renderStrip(true, lengths[0], topMargins[0])}
333280
{this.renderStrip(false, lengths[1], topMargins[1])}
@@ -391,7 +338,7 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
391338

392339
renderWithFading = (skeleton: any) => {
393340
const {isAnimating} = this.state;
394-
const {children, renderContent, customValue, contentData} = this.props;
341+
const {children, renderContent, customValue} = this.props;
395342

396343
if (isAnimating) {
397344
return (
@@ -405,8 +352,7 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
405352
</Animated.View>
406353
);
407354
} else if (_.isFunction(renderContent)) {
408-
const _customValue = customValue || contentData;
409-
return renderContent(_customValue);
355+
return renderContent(customValue);
410356
} else {
411357
return children;
412358
}
@@ -441,13 +387,8 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
441387
renderContent,
442388
showContent,
443389
customValue,
444-
contentData,
445390
template,
446391
listProps,
447-
size,
448-
contentType,
449-
hideSeparator,
450-
showLastSeparator,
451392
height,
452393
width,
453394
colors,
@@ -462,13 +403,8 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
462403
showContent,
463404
renderContent,
464405
customValue,
465-
contentData,
466406
template,
467407
listProps,
468-
size,
469-
contentType,
470-
hideSeparator,
471-
showLastSeparator,
472408
height,
473409
width,
474410
colors,
@@ -483,13 +419,17 @@ class SkeletonView extends Component<SkeletonViewProps, SkeletonState> {
483419
<View {...others}>
484420
{_.times(times, index => {
485421
const key = timesKey ? `${timesKey}-${index}` : `${index}`;
422+
const _listProps = {
423+
...listProps,
424+
hideSeparator: listProps?.hideSeparator || (!listProps?.showLastSeparator && index === times - 1)
425+
};
486426
return (
487427
<SkeletonView
488428
{...passedProps}
429+
listProps={_listProps}
489430
key={key}
490431
testID={`${testID}-${index}`}
491432
renderContent={index === 0 ? renderContent : this.renderNothing}
492-
hideSeparator={this.hideSeparator || (!this.showLastSeparator && index === times - 1)}
493433
times={undefined}
494434
/>
495435
);

0 commit comments

Comments
 (0)