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

99
Visualizações
React Native stops executing

I have the following code

  <DocumentPicker
      onDone={(res: DocumentPickerResponse[]) => {
        if (res.hasOwnProperty('isCancel')) {
        } else {
          handleDocumentPicker(res);
          handleAttachmentResizing();
        }
        toggleDocumentPicker();
      }}

DocumentPicker allows the user to choose a video from their gallery, once they choose the video handleDocumentPicker gets the results array and sets my attachments array state. handleAttachmentResizing is then called to resize all the video attachments in my attachments state.

This is how the handleAttachmentResizing looks like

 const handleAttachmentResizing = async () => {
console.log('handleAttachmentResizing called');
try {
  console.log('handleAttachmentResizing called try');
  lodash.forEach(newAttachments, async (item, idx) => {
    console.log('handleAttachmentResizing called try lodash');
    console.log('handleAttachmentResizing loop ', idx);
    if (!item.isCompressed && !item.isCompressing && isVideo(item.type)) {
      const resizedVideo = await resizeVideo(item, idx);
      if (resizedVideo) {
        const uri = await moveFile(resizedVideo);
        const update: Attachment = {
          ...item,
          isCompressed: true,
          isCompressing: false,
          uri,
        };
        updateAttachment(item.uri, update);
      }
    }
  });
} catch (err) {
  console.error('handleAttachmentResizing ', err);
}
console.log('handleAttachmentResizing called');

};

And resizeVideo looks like this

  const resizeVideo = async (attachment: Attachment, idx: number) => {
console.log('resizeVideo called');
try {
  return await Video.compress(
    attachment.uri,
    {
      compressionMethod: 'auto',
      getCancellationId: (cancellationId) =>
        setVideoCancellationToken(cancellationId),
    },
    (progress) => {
      if(mounted.current){
      const updated: Attachment = {
        ...attachment,
        progress,
        isCompressing: true,
      };
      updateAttachment(attachment.uri, updated);
    }else {
      //Video.cancelCompression()
      handleRemoveAttachment(attachment, idx);
    }
    },
  );
} catch (err) {
  console.error('resizeVideo ', err);
  handleRemoveAttachment(attachment, idx);
}
};

I'm not sure why but handleAttachmentResizing only prints handleAttachmentResizing called try and ends there, if I choose another file in my gallery, it mysteriously continues executing.

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