-
Notifications
You must be signed in to change notification settings - Fork 408
-
Hi, Reacfire team I need a guide on why this is happening and how to fix this .
I am using two hooks of Reactfire useDatabaseListData to get the URLs of the images from the real-time database and useStorageDownloadURL to get and display the images.
For some reason the "for loop" ran only the first time (even if I checked the imagesarray.length in the last tried got the final list of images).
function Displayphotos(photosmetada)
{
const urlminimalblankimage="https://firebasestorage.googleapis.com/xxxxxxxxxxxxxxxxx..."
const minimalblankobject=[{"author":"","id":"07355838-54d7-436e-9bcc-6688467c2990","timestamp":"","url":urlminimalblankimage}];
if (typeof (photosmetada.photosmetada.user) !== 'undefined')
{
var gameid = photosmetada.photosmetada.gameid;
}
var database = useDatabase();
var querypath = '/photos/' + gameid;
const photosRef = refdatabase(database, querypath);
const objectlistofimages = useDatabaseListData(photosRef);
var imagesarray=objectlistofimages.data;
if (typeof (imagesarray) === 'undefined'){
imagesarray=minimalblankobject;
}
const photoRefoneimageblank = ref(storage,urlminimalblankimage);
var imagesarraylength=imagesarray.length;
for (let i=0; i < imagesarraylength;i++)
{
console.log(i);
console.log(imagesarraylength);
var urlimageref=imagesarray[i].url;
var photoRefoneimage = ref(storage,urlimageref);
var { status, data: imageURL } = useStorageDownloadURL((typeof (imagesarray) !== 'undefined') ? photoRefoneimage:photoRefoneimageblank);
if (status === 'loading')
return <span>loading...</span>;
return <img src={imageURL} alt="game NSYL" />
}
}
Pls any guide.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment