Skip to content

Commit 290cae2

Browse files
committed
[fix] Image throws error if packager asset isn't resolved
Fix #2370
1 parent 93b1d04 commit 290cae2

File tree

1 file changed

+5
-0
lines changed
  • packages/react-native-web/src/exports/Image

1 file changed

+5
-0
lines changed

packages/react-native-web/src/exports/Image/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ function resolveAssetUri(source): ?string {
113113
if (typeof source === 'number') {
114114
// get the URI from the packager
115115
const asset = getAssetByID(source);
116+
if (asset == null) {
117+
throw new Error(
118+
`Image: asset with ID "${source}" could not be found. Please check the image source or packager.`
119+
);
120+
}
116121
let scale = asset.scales[0];
117122
if (asset.scales.length > 1) {
118123
const preferredScale = PixelRatio.get();

0 commit comments

Comments
 (0)