import image in react js 1

import image in react js

//import imgs in a different js file
import lostImage from './assets/img/illustrations/lost.svg';
export { lostImage }; 

//import in the component to use it
import {lostImage} from './images.js'

Here is what the above code is Doing:
1. We’re importing the image in a separate file.
2. We’re exporting the image from the separate file.
3. We’re importing the image in the component where we want to use it.

This is a good way to keep your code organized.

Similar Posts