Error Including Image in App

Asked

Viewed 648 times

1

I created a default project, includes some images . png in the project in the main folder:

Project - image.png - index.android.js - .....

When running run-android an error is displayed indicating that the image was not located:

"error: bundling failed: "Unable to resolve module logoimg.png from C:\\Users\\Ayala\\Documents\\Developer\\React\\BrunoDantas\\index.android.js: Module does not exist in the module map n nThis Might be Related to https://github.com/facebook/react-native/issues/4968\nto resolve Try the following: n 1. Clear Watchman watches: watchman watch-del-all.\n 2. Delete the node_modules Folder: rm -rf node_modules && npm install.\3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache."

Someone’s been through this trouble?

  • You can show the code you tried to insert the image into ?

2 answers

0


Try this:

<Image source={require('./my-icon.png')} />

0

Summarizing the path to the image is wrong. In question Voce says the name of the image is image.png but in the log this logoimg.png so there’s already something wrong there.

In React images (modules too) have relative path if your index.android.js and the logoimg.png are on the same level or would look something like:

<Image source={require('./logoimg.png')}/>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.