From d6ded2f807561720e43662f5e020fc4901211cc1 Mon Sep 17 00:00:00 2001 From: Varun Vachhar Date: Fri, 4 Mar 2016 07:31:38 -0800 Subject: [PATCH] Display a warning when using src property for an Image rather than source. Summary:When using the `Image` component with a `src` property instead of `source` the component fails silently. vjeux suggested to add a warning (https://twitter.com/Vjeux/status/704509214937317378). Tested with the UIExplorer example on iOS and Android simulators. Closes https://github.com/facebook/react-native/pull/6221 Differential Revision: D3011659 Pulled By: mkonicek fb-gh-sync-id: c9bae6c802c173ef85d9c4552747db994c58906e shipit-source-id: c9bae6c802c173ef85d9c4552747db994c58906e --- Libraries/Image/Image.android.js | 4 ++++ Libraries/Image/Image.ios.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index 7adbe13c2..d2e1a177c 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -161,6 +161,10 @@ var Image = React.createClass({ console.warn('source.uri should not be an empty string'); } + if (this.props.src) { + console.warn('The component requires a `source` property rather than `src`.'); + } + if (source && source.uri) { var {width, height} = source; var style = flattenStyle([{width, height}, styles.base, this.props.style]); diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js index 43f694b43..785c9f083 100644 --- a/Libraries/Image/Image.ios.js +++ b/Libraries/Image/Image.ios.js @@ -210,6 +210,10 @@ var Image = React.createClass({ RawImage = RCTImageView; } + if (this.props.src) { + console.warn('The component requires a `source` property rather than `src`.'); + } + if (this.context.isInAParentText) { RawImage = RCTVirtualImage; if (!width || !height) {