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 https://github.com/facebook/react-native/pull/16880

Differential Revision: D6369396

Pulled By: shergin

fbshipit-source-id: c4ae4dbb77d0fce6cbd7a42d1957d16112b24549
This commit is contained in:
Nathan Brown 2017-11-18 17:15:24 -08:00 committed by Facebook Github Bot
parent 1b22d49ae8
commit 44c16499fd
2 changed files with 2 additions and 2 deletions

View File

@ -274,7 +274,7 @@ var Image = createReactClass({
} }
if (this.props.children) { 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))) { if (source && (source.uri || Array.isArray(source))) {

View File

@ -374,7 +374,7 @@ const Image = createReactClass({
} }
if (this.props.children) { 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 ( return (