I don't really understand one moment. Let's say I have a component which conditionally renders data like this:
<div>
{isLoading ? <img src="../pathname/img.jpg" alt="loading" /> : <Page />}
</div>
Image is not rendered this way, shows a broken file icon. However, if I import the same image it works just fine:
import loadingImage from "../pathname/img.jpg"
<div>
{isLoading ? <img src={loadingImage} alt="loading" /> : <Page />}
</div>
I use npm start
and my editor is VS Code. Do you know may be what is the reason to import it and not just simply provide a path name in src
even if path is the same? The path I provided and file name was 100% correct in the first example.