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
This commit is contained in:
Varun Vachhar 2016-03-04 07:31:38 -08:00 committed by Facebook Github Bot 6
parent e64987d780
commit d6ded2f807
2 changed files with 8 additions and 0 deletions

View File

@ -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 <Image> 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]);

View File

@ -210,6 +210,10 @@ var Image = React.createClass({
RawImage = RCTImageView;
}
if (this.props.src) {
console.warn('The <Image> component requires a `source` property rather than `src`.');
}
if (this.context.isInAParentText) {
RawImage = RCTVirtualImage;
if (!width || !height) {