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

97
Views
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
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!