Where to put images in a react-native project?

In image assets folder, create index.js file and put following:

    const images = {
        main_bg: require('./background.png'),
        main_logo: require('./auth/home_title.png'),
        ///you can add more many images like this here.
    };


module.exports = images;

When using the images, you can do like this:

import Images from '../../assets/index'; ...


You can add image folder to src(src/image/index.js). Image folder add index.js file create and add whole app image. In index.js file set

export const IMAGENAME = require('./icon.png'); 

When import image folder

import { IMAGENAME } from '../image';

Use image:

<Image source={ IMAGENAME } />

You can add image to image folder and set path to index file. Hope this will help you.


To add a static image to your app, place it somewhere in your source code tree and reference it like this:

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

please see the below link for more explanation:

https://reactnative.dev/docs/images

Tags:

React Native