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

144
Views
Adding images to firebase storage with react native

Can you help me what is my mistake here? He did that in a video I watched.

The error I get is this;

TypeError: undefined is not an object (evaluating 'media.cancelled')

const [isUploading, setIsUploading] = useState(false);
  const [isPaused, setIsPaused] = useState(false);
  const [downloadUrl, setDownloadUrl] = useState();
  const [uploadTask, setUploadTask] = useState();
  const [uploadTaskSnapshot, setUploadTaskSnapshot] = useState({});


    
const onTakePhoto = () => {
        launchCamera({ mediaType: 'photo', saveToPhotos:true }, onMediaSelect())
      };

  const onSelectImagePress = () => {
    launchImageLibrary({ mediaType: 'photo', saveToPhotos:true }, onMediaSelect())
  };

  const onMediaSelect = async media => {
    if (!media.didCancel) {
      setIsUploading(true);
      const ref = storage().ref(media.assets[0].fileName);

      const task = ref.putFile(media.assets[0].uri);

      setUploadTask(task);
      task.on('state_changed', taskSnapshot => {
        setUploadTaskSnapshot(taskSnapshot);
      });

      task.then(async () => {
        const downloadURL = await ref.getDownloadURL();
        setDownloadUrl(downloadURL);
        alert(downloadUrl)
        setIsUploading(false);
        setUploadTaskSnapshot({});
      })
    }
  };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I belive onMediaSelect is a function that takes a media parameter and you're calling it without providing it in onTakePhoto and onSelectImagePress callbacks.

Do you know what is the the signature of the launchCamera function?

about 4 years ago · Juan Pablo Isaza Report
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!