N
N
Nikita Shchypylov2017-07-20 13:34:58
JavaScript
Nikita Shchypylov, 2017-07-20 13:34:58

Why can't I see the image in the React component?

And so, this structure:

-public
--index.html
-src
--components
---myComp.js
--files
---n-logo.js

Here's how I write in myComp.js :
<img src="../files/n-logo.svg" alt=""/>
but the picture is not found. Tried it like this:
<img src="/src/files/n-logo.svg" alt=""/>- absolute path, also not
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vit, 2017-07-20
@Nikulio

You should not specify the path in the file system, but the URL relative to the folder that you have webroot. Wang that this is public. Those. you need to put the image in public and specify the URL there.

R
Roman Alexandrovich, 2017-07-20
@RomReed

In my project, all files are in public and I specify the path to the files './files'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question