In a create-react-app
app, I am using React Image Gallery. I am having the user select one of my galleries and then pass the array containing the image paths to the <ImageGallery items={ images } />
component. It works if I use absolute paths, like so:
{'images':
[
{ original: 'https://domain.tld/image_01.jpg' },
{ original: 'https://domain.tld/image_02.jpg' }
]
}
My file structure is as follows:
>src
>base
App.js // this is where the array is assigned to state
>data
>containertypes
>js
SlideShow.js // this is where the array is read from props and used in <ImageGallery />
>img
image_01.jpg
image_02.jpg
I tried using relative paths like so:
{'images':
[
{ original: '../../../img/image_01.jpg' },
{ original: '../../../img/image_02.jpg' }
]
}
Unfortunately, to no avail (also tried one less and one more '..'). How can I use relative paths in React without having a chance to use import statements on each image file?
At this point, considering the notorious troubles with paths in React (see this or this or this) , I do not think that this is a problem with the image gallery component, but a general React issue.