Skip to content

Commit 57484f6

Browse files
authored
CardSection - remove 'source' (use 'imageSource') (#1551)
1 parent 6915130 commit 57484f6

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

generatedTypes/src/components/card/CardSection.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export declare type CardSectionProps = ViewProps & {
3232
* Will be used for the background when provided
3333
*/
3434
imageSource?: ImageSourcePropType;
35-
source?: ImageSourcePropType;
3635
/**
3736
* The style for the background image
3837
*/
@@ -68,7 +67,6 @@ declare const _default: React.ComponentClass<ViewProps & {
6867
* Will be used for the background when provided
6968
*/
7069
imageSource?: ImageSourcePropType | undefined;
71-
source?: ImageSourcePropType | undefined;
7270
/**
7371
* The style for the background image
7472
*/

src/components/card/CardSection.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import _ from 'lodash';
22
import React, {PureComponent} from 'react';
33
import {StyleSheet, ViewStyle, ImageStyle, ImageSourcePropType, StyleProp} from 'react-native';
4-
import {LogService} from '../../services';
54
import {asBaseComponent} from '../../commons/new';
65
import View, {ViewProps} from '../view';
76
import Text, {TextProps} from '../text';
87
import Image, {ImageProps} from '../image';
98
import asCardChild, {asCardChildProps} from './asCardChild';
109

10+
1111
type ContentType = TextProps & {text?: string};
1212

1313
export type CardSectionProps = ViewProps & {
@@ -36,7 +36,6 @@ export type CardSectionProps = ViewProps & {
3636
* Will be used for the background when provided
3737
*/
3838
imageSource?: ImageSourcePropType;
39-
source?: ImageSourcePropType; // TODO: remove after deprecation
4039
/**
4140
* The style for the background image
4241
*/
@@ -56,14 +55,6 @@ type Props = CardSectionProps & asCardChildProps;
5655
class CardSection extends PureComponent<Props> {
5756
static displayName = 'Card.Section';
5857

59-
constructor(props: Props) {
60-
super(props);
61-
62-
if (props.source) {
63-
LogService.deprecationWarn({component: 'CardSection', oldProp: 'source', newProp: 'imageSource'});
64-
}
65-
}
66-
6758
renderContent = () => {
6859
const {content, leadingIcon, trailingIcon, contentStyle, testID} = this.props;
6960
if (!leadingIcon && !trailingIcon && _.isEmpty(content)) {
@@ -92,15 +83,14 @@ class CardSection extends PureComponent<Props> {
9283
};
9384

9485
renderImage = () => {
95-
const {source, imageSource, imageStyle, imageProps, testID} = this.props;
96-
const finalSource = imageSource || source;
86+
const {imageSource, imageStyle, imageProps, testID} = this.props;
9787

9888
// not actually needed, instead of adding ts-ignore
99-
if (finalSource) {
89+
if (imageSource) {
10090
return (
10191
<Image
10292
testID={`${testID}.image`}
103-
source={finalSource}
93+
source={imageSource}
10494
style={imageStyle}
10595
customOverlayContent={this.renderContent()}
10696
{...imageProps}
@@ -111,18 +101,16 @@ class CardSection extends PureComponent<Props> {
111101

112102
render() {
113103
const {
114-
source,
115104
imageSource,
116105
context: {borderStyle},
117106
style,
118107
...others
119108
} = this.props;
120-
const finalSource = imageSource || source;
121109

122110
return (
123111
<View style={[styles.container, borderStyle, style]} {...others}>
124-
{finalSource && this.renderImage()}
125-
{!finalSource && this.renderContent()}
112+
{imageSource && this.renderImage()}
113+
{!imageSource && this.renderContent()}
126114
</View>
127115
);
128116
}

0 commit comments

Comments
 (0)