I'm having this function that downloads an image from firebase storage.
() => {
// gets the functions from storage refences the image storage in firebase by the children
// gets the download url then sets the image from firebase as the value for the imgUrl:
storage
.ref(`images/${user?.uid}`)
.child(ImgAsFile.name)
.getDownloadURL()
.then((fireBaseImgUrl) => {
setImgUrl(fireBaseImgUrl);
console.log("ImgUrl: ", ImgUrl);
console.log("FireBaseImgUrl: ", fireBaseImgUrl);
history.push("/home");
});
Where setImgUrl
is a state Modifier of state variable ImgUrl
This is what the state variable I have defined
const [ImgUrl, setImgUrl] = useState("");
But I don't know why ImgUrl
is not getting the downloaded URL but I can see fireBaseImgUrl
getting the desired URL.