ivpusic / react-native-image-crop-picker

iOS/Android image picker with support for camera, video, configurable compression, multiple images and cropping
MIT License
6.12k stars 1.56k forks source link

Picker works only once #275

Open minhchu opened 7 years ago

minhchu commented 7 years ago

Version

Tell us which versions you are using:

Platform

Tell us to which platform this issue is related

Expected behaviour

I have a button like this:

<Button 
  onPress={() => {
        ImagePicker.openPicker({
          multiple: true // I tried with false too
        }).then(images => {
          alert(JSON.stringify(images));
        });
  }} 
  title="Open Gallery" 
/>

The first time I click on the button and select an image, it works and the alert popup is shown. After that, I still can pick an image but there is no popup anymore.

Did I do anything wrong or there is a real bug ?
Thank you.

ivpusic commented 7 years ago

can you add .catch and check if you get error when you select for the second time?

minhchu commented 7 years ago

Thanks for your quick reply. I tried but it didnt catch anything.

ivpusic commented 7 years ago

what if instead of alert you put console.log?

minhchu commented 7 years ago

It is working as expected. Still dont know why alert didnt work Thank you.

sergiocloud commented 7 years ago

Hi @ivpusic , I have the same problem. When I can only pick 1 image, after select the first the component response with an array with one item, it doesn't catch anything beacause it is working fine but only responding with one image.

Here is my code: ImagePicker.openPicker({ width: 400, compressImageMaxWidth: 400, height: 400, compressImageMaxHeight: 400, multiple: true, includeBase64: true, maxFiles: 10, mediaType: 'photo' }).then(res => { console.log('res', res); if(res) { let results = [] res.map((image, index) => { if(index < 10) results.push({isStatic: true , uri: image.path, data: 'data:image/jpeg;base64,' + image.data}) }) this.setState({images: results}) } }).catch(error => { console.log('ImagePicker error', error); });

sarahmarciano commented 7 years ago

I have the same problem: on android it's working but on ios it's working just the first time then it's not working anymore and I can't catch anything @sergiocloud how did u solve it?

sergiocloud commented 7 years ago

I have set an Alert inside the ImagePicker's promise asking the user if want to upload more pictures, if yes I call the function again. Every result is pushing in an array.

It's not the best option but I'm busy for searching other method...

JslinSir commented 6 years ago

I have the same problem

pqminh commented 6 years ago

+1 maxFiles not working on android device. "react-native": "^0.47.2", "react-native-image-crop-picker": "^0.21.1", pls support android 👯 . tks. @ivpusic

reza7rm commented 5 years ago

Same here. the first time it works, the second time codes in then block do not work!

fcornejor commented 5 years ago

Any progress on this? Only works once. Second time, camera shows for a sec and then disappears. Same with gallery. Can you help me?

ReemaVinodGangdev commented 3 years ago

Same error. Any work around for this issue?

YASH-8102 commented 3 years ago

Same error. Any work around for this issue?

YASH-8102 commented 3 years ago

Any progress on this? Only works once. Second time, camera shows for a sec and then disappears. Same with gallery. Can you help me?

Did you find any solution buddy?

ReemaVinodGangdev commented 3 years ago

Same error. Any work around for this issue?

For me the problem was that the open camera button was in modal. to solve this, I close the modal first and then added setTimeOut of 3 seconds before opening camera or picker.

adnandothussain commented 3 years ago

Stuck on the same issue, do you guys get any solution ? For the first time it works and when you cancel the the gallery popup and again try to open it will stuck on that code and do nothing.

jyling commented 1 year ago

Stuck on the same issue, do you guys get any solution ? For the first time it works and when you cancel the the gallery popup and again try to open it will stuck on that code and do nothing.

timeout usually works the best, 500 is enough that user wont find it frustrating