U
U
Uasya882021-09-24 04:01:02
JavaScript
Uasya88, 2021-09-24 04:01:02

How to display images in react?

Good afternoon.
The question is hackneyed, we repeatedly discuss it, with a bunch of decisions, and so on .. But!

Problem. Images are not displayed in the project.
React, jsx component.

component path:
/src/components/post/post.jsx

Tried to upload image to: -public folder -public /images folder
-src folder -src /images -in /src/components/images Image is displayed in two cases: 1 ) if it is in the folder with the component. Near. 2) or if it's stupid to import, and insert import mops from './images/mops.jpeg'; src={mops} I don't understand what the problem is, as it didn't happen in other projects. Tried a bunch of things, came up with nothing.





I think you can stick it through webpack by writing the paths there. But I don’t really want to mess with him because of one picture.
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JS Noob, 2021-09-24
@JS_Noob

2) or if it's stupid to import, and insert
import mops from './images/mops.jpeg';
src={mops}

This is the most normal way to insert a static image.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question