Permalink
Browse files

Mention <ImageBackground> when error is thrown

Summary:
Improve the error message shown when you try to nest components in an
`<Image>` component by referencing the `<ImageBackground>` component.

It would be helpful if the error message displayed when you try to nest components in an `<Image>` component mentioned the `<ImageBackground>` component. Especially since this component is not yet well documented.

[IOS][MINOR][Libraries/Image/Image.ios.js] - Surfaced `<ImageBackground>` in error message
[ANDROID][MINOR][Libraries/Image/Image.android.js] - Surfaced `<ImageBackground>` in error message
Closes #16880

Differential Revision: D6369396

Pulled By: shergin

fbshipit-source-id: c4ae4dbb77d0fce6cbd7a42d1957d16112b24549
  • Loading branch information...
nkabrown authored and facebook-github-bot committed Nov 19, 2017
1 parent 1b22d49 commit 44c16499fdc4665298f6c88b9ffee626fa1fc969
Showing with 2 additions and 2 deletions.
  1. +1 −1 Libraries/Image/Image.android.js
  2. +1 −1 Libraries/Image/Image.ios.js
@@ -274,7 +274,7 @@ var Image = createReactClass({
}
if (this.props.children) {
throw new Error('The <Image> component cannot contain children. If you want to render content on top of the image, consider using absolute positioning.');
throw new Error('The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.');
}
if (source && (source.uri || Array.isArray(source))) {
@@ -374,7 +374,7 @@ const Image = createReactClass({
}
if (this.props.children) {
throw new Error('The <Image> component cannot contain children. If you want to render content on top of the image, consider using absolute positioning.');
throw new Error('The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.');
}
return (

0 comments on commit 44c1649

Please sign in to comment.