mercredi 1 septembre 2021

My images in react will not load onto the page. How do I load a local image file?

Trying to add an image from my assets folder, but can't seem to reach back that far?

<img class='fade-in' src={'.../assets/images/logos/SWSLogoNOBG.png'} />

Can I not reach back that far with the dots? I can use two and it works, but is three too much?

I've also tried

import SWSLogo from '.../assets/images/logos/SWSLogoNOBG.png';

then done

<img class='fade-in' src={SWSLogo}/>

but that also doesn't work?

I feel super dumb and could use some help cause this one little problem has taken me two days of trying and I've made zero progress.

Edit:

I've made it work, but only by moving my image file into the same folder as my Home.js file.

Can react not reach files outside of the immediate directory? Why is this so stupid?




Aucun commentaire:

Enregistrer un commentaire