Search code examples
imagereact-nativeassets

React Native: image not visible


Using React Native v0.61.5. The images are visible (iOS and Android) in dev mode only on the emulator or on the phone attached with cable and Terminal running. Once I close the terminal and I open again the app the images are not visible.

Code for the image <Image source={require("../assets/image.png")} />

Code I found for copy the images from the ./assets folder to /res: npx react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

this code creates folders with the images I use but when I close the terminal and disconnect the phone the images are not visible.

Does it happen to you too? What should I do for be able to load the images without the terminal running?


Solution

    1. You should use a drawable folder in ProjectName/android/app/src/main/res directory for android and for ios use Images.xcassets drag and drop your images into this.

    2. Add Images in this folder.

    3. Access Image Like this <Image source={{uri:"imagename"}}/>