Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda