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

Getting "Illegal callback invocation from native module. This callback type only permits a single invocation from native code." #1097

Open nihp opened 5 years ago

nihp commented 5 years ago

I am getting illegal callback error while click on the choose. Here so I need to click choose two times.

Version react-native-image-crop-picker v0.22.0 react-native v0.58.4

Platform iOS

Expected behaviour Need to crop an image on the first click on the choose

Actual behaviour Illegal callback invocation from native module. This callback type only permists a single invocation from native code.

Steps to reproduce

Attachments

 // Opens the library image in Library.js screen
import ImagePicker from 'react-native-image-picker';
     ImagePicker.launchImageLibrary(options, (response)  => {
            if (response.didCancel) {
              console.warn('User cancelled photo picker');
            }
            else if (response.error) {
              console.warn('ImagePicker Error: ', response.error);
            }
            else {
             this.props.navigation.navigate('CropWindow', { screenName: 'CropImage',uri: response.uri});
            }
import ImagePicker from 'react-native-image-crop-picker';
    ImagePicker.openCropper({
                path: response,
                width: deviceWidth,
                height: deviceWidth*5/4
             }).then(image => {
                this.props.navigation.navigate('ShowAllCroppedImage', {uri: response.uri, croppedImage: this.croppedImage.bind(this)});
              })
              .catch((err) => {
                console.log("openCropper error = " + err)
              });

Screenshot 2019-08-19 at 11 32 17 AM

jqn commented 5 years ago

@nihp I also ran into this scenario. To add to this issue the image picker is slow in iOS which would most likely prompt the user to tap on buttons more than once.

nihp commented 5 years ago

@jqn Did you have any solution for this? If I add an alert inside while launching library it works fine.

nihp commented 5 years ago

@jqn I got a solution for the above

I have used both the library in a screen as below. Here after launching the library I have use crop window. Just works fine.

import ImagePicker from 'react-native-image-picker';
import ImageCropPicker from 'react-native-image-crop-picker';

     ImagePicker.launchImageLibrary(options, (response)  => {
            if (response.didCancel) {
              console.warn('User cancelled photo picker');
            }
            else if (response.error) {
              console.warn('ImagePicker Error: ', response.error);
            }
            else {
              ImageCropPicker.openCropper({
                path: response,
                width: deviceWidth,
                height: deviceWidth*5/4
             }).then(image => {
                this.props.navigation.navigate('ShowAllCroppedImage', {uri: response.uri, croppedImage: this.croppedImage.bind(this)});
              })
              .catch((err) => {
                console.log("openCropper error = " + err)
              });
}
jqn commented 5 years ago

@nihp thanks I haven't had a chance to look into but I'll give your fix a shot.