From 884018a98d15c269dc084753bd5e1d748f26710e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20B=C3=BCrger?= Date: Sun, 11 Sep 2022 01:38:30 +0200 Subject: [PATCH] Align android image style / source logic with ios --- Libraries/Image/Image.android.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index dd5241326ff3e1..bde10a4e08dd8e 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -129,7 +129,11 @@ export type ImageComponentStatics = $ReadOnly<{| /* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's * LTI update could not be added via codemod */ const BaseImage = (props: ImagePropsType, forwardedRef) => { - let source = getImageSourcesFromImageProps(props); + let source = getImageSourcesFromImageProps(props) || { + uri: undefined, + width: undefined, + height: undefined, + }; const defaultSource = resolveAssetSource(props.defaultSource); const loadingIndicatorSource = resolveAssetSource( props.loadingIndicatorSource, @@ -147,22 +151,19 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => { ); } - if (source && !source.uri && !Array.isArray(source)) { - source = null; - } - let style; let sources; - if (!Array.isArray(source) && source?.uri != null) { + if (Array.isArray(source)) { + style = flattenStyle([styles.base, props.style]) || {}; + sources = source; + } else { const {width = props.width, height = props.height, uri} = source; - style = flattenStyle([{width, height}, styles.base, props.style]); - sources = [{uri: uri, width: width, height: height}]; + style = flattenStyle([{width, height}, styles.base, props.style]) || {}; + sources = [source]; + if (uri === '') { console.warn('source.uri should not be an empty string'); } - } else { - style = flattenStyle([styles.base, props.style]); - sources = source; } const {height, width, ...restProps} = props;