Error Including an Image in the app

1

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

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

Running run-android displays an error indicating that the image was not found:

  

"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    link \ 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 . \ n 3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache . "

Has anyone ever had this problem?

    
asked by anonymous 26.07.2017 / 04:06

2 answers

0

Try this:

<Image source={require('./my-icon.png')} />
    
31.07.2017 / 19:36
0

In short, the path to the image is wrong. In the question you say that the image name is image.png but in the log it is logoimg.png so there is already something wrong there.

In React, the images (modules also) have the relative path if their index.android.js and logoimg.png are at the same level would look something like:

<Image source={require('./logoimg.png')}/>
    
25.09.2017 / 16:40