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

App closes when image selection is cancelled #1638

Open Olha-Khomlyak opened 3 years ago

Olha-Khomlyak commented 3 years ago

Version

Platform

Expected behaviour

After user cancel image selection (closes gallery by clicking back button ) app should return to the screen where user can select image

Actual behaviour

After user cancel image selection (closes gallery by clicking back button ) app stops working and promote "App has stopped. Open app again" appears. No error is consoled log, just stops working

Works fine when image is selected. On iOS works fine

Steps to reproduce

    ImagePicker.openPicker({
        mediaType: 'image',
        width: 300,
        height: 300,
        cropping: true
    }).then(image => {
        console.log('selected media ==', image);
    })
        .catch(er => {
            console.log(er);
            alert(er);
            if (er.code === 'E_PICKER_CANCELLED') {
                // here the solution
                return false;
            }
        });
snehsagarajput commented 3 years ago

This is a long known issue with React Native for iOS https://github.com/react-native-modal/react-native-modal/issues/30

Olha-Khomlyak commented 3 years ago

This is a long known issue with React Native for iOS react-native-modal/react-native-modal#30

the thing is there is no problem with iOS, onClose does not work on Android

BuiHung1612 commented 3 years ago

const pickImage = () => { ImagePicker.openPicker({ multiple: true, // mediaType: 'photo', compressImageMaxWidth: 1024, compressImageMaxHeight: 1024, compressImageQuality: 1, }) .then((images: any) => {

            console.log('images picked', images);

        }).catch(e => {
            console.log('[WARNING]', e.message)
        }
        )

};

please return it as e.message