Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

222
Views
firebase getDownloadURL not updating my state in the react js code

the problem: that user will upload image and the

  1. code will return the download url

  2. set the state in the url

  3. store the url in the local storage the code that doing the following is : import {

         getDownloadURL,
         ref,
         uploadBytesResumable,
         UploadTask,
     } from 'firebase/storage';
     import { IState } from '../store/state';
     import { storage } from '../../firebase';
    
     const getDownload = async (uploadTask: UploadTask, state: IState) => {
         const downloadUrl = getDownloadURL(uploadTask.snapshot.ref).then(
             (downloadURL) => {
                 console.log('File available at', downloadURL);
                 localStorage.setItem('logoUrl', downloadURL);
                 return downloadURL;
             }
         );
         return downloadUrl;
     };
     export const uploadLogo = async (file: any, state: IState) => {
         //
         if (!file) return;
         const sotrageRef = ref(storage, `files/${file.name}`);
         const uploadTask = uploadBytesResumable(sotrageRef, file);
         return uploadTask.on(
             'state_changed',
             (snapshot: { bytesTransferred: number; totalBytes: number }) => {
                 const prog = Math.round(
                     (snapshot.bytesTransferred / snapshot.totalBytes) * 100
                 );
             },
             (error: any) => console.log(error),
             async () => {
                 state.logoUrl = await getDownload(uploadTask, state);
             }
         );
     };
    

the user press on button to upload his image then the local storage is updated with the new URL but the state isn't

ps: i am using Overmind to manage my state

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!