You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checklist before opening an issue
Lots of issues are opened that are unrelated to this package, please take a moment to ensure the issue is not on your end 馃檹.
[X ] Did you try google?
[X ] Did you search for previous Issues in this repo?
Describe the bug
Hi all, I'm trying to modify the existing example in the repo (https://github.com/xiaolin/react-image-gallery#example)
What I try to do, is to fetch custom images and not have a static list in the component. The links to the images are in my backend.
When I load my page with the dynamic list fetchedImages and pass this variable as props, I only get the play button and the fullscreen button displayed from the gallery but no images
Image Gallery Version
What version of react-image-gallery are you using?
"react-image-gallery": "^1.3.0",
You are passing to the ImageGallery a "non reactive" list, aka a normal variable.
When you modify the content of the fetchedImages array, React knows nothing about that change and no additional render is performed.
One way to update the gallery with fetched images, is to make fetchedImages a state:
const [fetchedImages, setFetchedImages] = React.useState([]); // declare fetchedImages as state instead of plane array
React.useEffect(() => {
async function fetchData() {
// ... fetch and process images
setFetchedImages(imageObject) // instead of fetchedImages.push(imageObject);
}
fetchData();
}, []);
Checklist before opening an issue
Lots of issues are opened that are unrelated to this package, please take a moment to ensure the issue is not on your end 馃檹.
Describe the bug
Hi all, I'm trying to modify the existing example in the repo (https://github.com/xiaolin/react-image-gallery#example)
What I try to do, is to fetch custom images and not have a static list in the component. The links to the images are in my backend.
When I load my page with the dynamic list fetchedImages and pass this variable as props, I only get the play button and the fullscreen button displayed from the gallery but no images
Image Gallery Version
What version of
react-image-gallery
are you using?"react-image-gallery": "^1.3.0",
**My Code **\
Expected behavior
Fetched images in the fetchedImages variable should be displayed
Screenshots
Dynamic images
Static images
Additional context\
These are my two different objects. They're the same from the properties but their value is different. I guess it's ok that way.
The text was updated successfully, but these errors were encountered: