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

98
Vistas
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 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