'How can I import image file with react?

I have a images files but react is not take them ı cant import like that. Otherwise when i try

<img src={require("/FileAdress")} className="Logo" alt="logo" /> Nothings came and not recognized

whats the problem anyone help ? enter image description here

I have a logo folder inside image logo.png but ı cant see now



Solution 1:[1]

If you are using create-react-app you can add an image this way:

import Logo from 'path/to/logo.png';

<img src={Logo} className="Logo" alt="logo" />

Solution 2:[2]

IF you are planning to deploy your react app later on with Netlify I would suggest you store your images in the public folder. That way then they can be easily accessed during development but they would also not cause any errors later on when deployment.

Example code:

<img
className='deleteBtn'
**src='/images/delete__btn.png'**
alt='Delete a product if admin'
/>

Example snapshot

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lissettdm
Solution 2 Stefan Georgiev