title: How to pass data from Child function to parent component in react
body: <p>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)</p>
  <p>myFunc.js</p>
  <pre><code>export const handleUploadImage = (image: any, folderName = &quot;adhaar&quot;) =&gt;{
      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) =&gt;{
          storageRef.child(file.name).getDownloadURL().then(url =&gt; { 
              console.log(url)
          })        
        },(error) =&gt;{
          throw error
        },() =&gt; {        
          uploadTask.snapshot.ref.getDownloadURL().then((url) =&gt;{           
            console.log(&quot;image download url:&quot;, url)
          })  
       }
     ) 
    }
  </code></pre>
  <p>parent Component</p>
  <pre><code>const ParentComponent = ()=&gt;
  {
      const [imageUrl setImageUrl] =useState()
  
        const getUrl = ()=&gt;
        {
          handleUploadImage(image)
            setImageUrl()
        }
  
  return(
     &lt;button onClick={getUrl}&gt; Get Url &lt;/button&gt;
  
  )
  
  
  }
  
  
  </code></pre>