Skip to content

Fix/imageSource deprecation #1115

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

Merged
merged 2 commits into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/card/CardSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type CardSectionProps = ViewProps & {
* Will be used for the background when provided
*/
imageSource?: ImageSourcePropType;
source?: ImageSourcePropType;
source?: ImageSourcePropType; // TODO: remove after deprecation
/**
* The style for the background image
*/
Expand All @@ -60,7 +60,7 @@ class CardSection extends PureComponent<Props> {
super(props);

if (props.imageSource) {
LogService.deprecationWarn({component: 'CardSection', oldProp: 'imageSource', newProp: 'source'});
LogService.deprecationWarn({component: 'CardSection', oldProp: 'source', newProp: 'imageSource'});
}
}

Expand Down Expand Up @@ -89,7 +89,7 @@ class CardSection extends PureComponent<Props> {

renderImage = () => {
const {source, imageSource, imageStyle, imageProps, testID} = this.props;
const finalSource = source || imageSource;
const finalSource = imageSource || source;

// not actually needed, instead of adding ts-ignore
if (finalSource) {
Expand All @@ -113,7 +113,7 @@ class CardSection extends PureComponent<Props> {
style,
...others
} = this.props;
const finalSource = source || imageSource;
const finalSource = imageSource || source;

return (
<View style={[styles.container, borderStyle, style]} {...others}>
Expand Down
8 changes: 4 additions & 4 deletions src/components/stateScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class StateScreen extends BaseComponent {
* The image source that's showing at the top. use an image that was required locally
*/
imageSource: PropTypes.oneOfType([PropTypes.object, PropTypes.number]),
source: PropTypes.oneOfType([PropTypes.object, PropTypes.number]),
source: PropTypes.oneOfType([PropTypes.object, PropTypes.number]), // TODO: remove after deprecation
/**
* To to show as the title
*/
Expand Down Expand Up @@ -54,13 +54,13 @@ export default class StateScreen extends BaseComponent {

}
if (props.imageSource) {
LogService.deprecationWarn({component: 'StateScreen', oldProp: 'imageSource', newProp: 'source'});
LogService.deprecationWarn({component: 'StateScreen', oldProp: 'source', newProp: 'imageSource'});
}
}

generateStyles() {
const {source, imageSource} = this.props;
const finalSource = source || imageSource;
const finalSource = imageSource || source;

const isRemoteImage = _.isObject(finalSource) && Boolean(finalSource.uri);
this.styles = createStyles(isRemoteImage);
Expand All @@ -69,7 +69,7 @@ export default class StateScreen extends BaseComponent {
render() {
// TODO: remove testId and imageSource after deprecation
const {title, subtitle, source, imageSource, ctaLabel, onCtaPress, testId, testID} = this.props;
const finalSource = source || imageSource;
const finalSource = imageSource || source;

return (
<View style={this.styles.container} testID={testID || testId}>
Expand Down