Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda