I want url in parent component and want to save it in imageUrl state, url is in handleUploadImage function ( image download url is the url which I need in parent component)
myFunc.js
export const handleUploadImage = (image: any, folderName = "adhaar") =>{
    let file = image;
    const storage = firebase.storage();
    const storageRef = storage.ref();
    const uploadTask = storageRef.child(`${folderName}/` + file.name).put(file);
  
    uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED,
      (snapshot) =>{
        storageRef.child(file.name).getDownloadURL().then(url => { 
            console.log(url)
        })        
      },(error) =>{
        throw error
      },() => {        
        uploadTask.snapshot.ref.getDownloadURL().then((url) =>{           
          console.log("image download url:", url)
        })  
     }
   ) 
  }
parent Component
const ParentComponent = ()=>
{
    const [imageUrl setImageUrl] =useState()
      const getUrl = ()=>
      {
        handleUploadImage(image)
          setImageUrl()
      }
return(
   <button onClick={getUrl}> Get Url </button>
)
}
 
     
     
    