diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index dd5241326ff3e1..4e8973bb69fe63 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}]; + 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; @@ -212,13 +213,12 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => { {hasTextAncestor => { if (hasTextAncestor) { - let src = Array.isArray(sources) ? sources : [sources]; return ( ); diff --git a/Libraries/Image/ImageViewNativeComponent.js b/Libraries/Image/ImageViewNativeComponent.js index ad724a5efb72ee..b0579012e46796 100644 --- a/Libraries/Image/ImageViewNativeComponent.js +++ b/Libraries/Image/ImageViewNativeComponent.js @@ -35,7 +35,9 @@ type Props = $ReadOnly<{ // Android native props shouldNotifyLoadEvents?: boolean, - src?: ?ResolvedAssetSource | $ReadOnlyArray<{uri: string, ...}>, + src?: + | ?ResolvedAssetSource + | ?$ReadOnlyArray>, headers?: ?{[string]: string}, defaultSrc?: ?string, loadingIndicatorSrc?: ?string, diff --git a/Libraries/Image/TextInlineImageNativeComponent.js b/Libraries/Image/TextInlineImageNativeComponent.js index 2ba778b217cc15..e2342da4c7368a 100644 --- a/Libraries/Image/TextInlineImageNativeComponent.js +++ b/Libraries/Image/TextInlineImageNativeComponent.js @@ -22,7 +22,7 @@ import type {ColorValue} from '../StyleSheet/StyleSheet'; type NativeProps = $ReadOnly<{ ...ViewProps, resizeMode?: ?ImageResizeMode, - src?: ?$ReadOnlyArray>, + src?: ?$ReadOnlyArray>, tintColor?: ?ColorValue, headers?: ?{[string]: string}, }>;