Skip to content

Commit

Permalink
Mention <ImageBackground> when error is thrown
Browse files Browse the repository at this point in the history
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 44c1649
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/Image/Image.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/Image.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 44c1649

Please sign in to comment.