Load all images from a directory? #71
|
Hello, and thanks for this project! Rather than hard-coding all the images I want to use, I'd like the component to read from a directory and automatically populate all the images. I'm new to React so I'm not sure how to go about this. Is this something that's currently possible with react-photo-album? If not, do you have a quick code snippet that would explain how to do it? Thanks! |
Replies: 1 comment 2 replies
|
Hi there! Unfortunately, this is not something that Generally speaking, there are two distinct approaches to what you'd like to achieve:
In the case of build time linking, the list of images has to be hard-coded one way or another, and your bundler would typically handle this for you.
Hope this helps. |
Hi there!
Unfortunately, this is not something that
react-photo-albumwould handle for you. Not even is this question outside the scope of this library, but it's even out of the scope of React. StackOverflow or similar developer forums may be more appropriate to address this topic. The answer to this question greatly depends on the framework/bundler you are using and may range from "yep, you can use workaround ABC" to "nope, this is not possible in XYZ."Generally speaking, there are two distinct approaches to what you'd like to achieve:
static linking at build time (I'll expand on this option below)
dynamic data retrieval at runtime (for instance, if you are hosting your images in ex…