Closed ajaymarathe closed 3 years ago
Hey guys, I m not getting any response in onImageCrop prop, don't know what I m doing wrong. here is what I m doing ->
onImageCrop
/* eslint-disable react-native/no-inline-styles */ import React, { useRef } from 'react'; import { Button, StatusBar, StyleSheet, View, Image } from 'react-native'; import { CropView } from 'react-native-image-crop-tools'; import Modal from 'react-native-modal'; const CropImage = ({ isVisible, uri, onClose }) => { const cropViewRef = useRef(); return ( <> <View style={{ flex: 1 }}> <Modal isVisible={isVisible}> <View style={{ flex: 1 }}> <StatusBar barStyle="dark-content" /> <View style={styles.container}> <CropView sourceUrl={uri} style={styles.cropView} ref={cropViewRef} onImageCrop={(res) => { console.log('res: ', res); }} keepAspectRatio aspectRatio={{ width: 16, height: 16 }} /> <Button title={'Get Cropped View'} onPress={() => { console.log('corp'); cropViewRef.current.saveImage(90); }} /> </View> </View> </Modal> </View> </> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, cropView: { flex: 1, }, }); export default CropImage;
Anyway nevermind, i fixed this by adding true to saveImage like this -> cropViewRef.current.saveImage(true, 90); Thanks for this nice library : )
true
saveImage
cropViewRef.current.saveImage(true, 90);
Hey guys, I m not getting any response in
onImageCrop
prop, don't know what I m doing wrong. here is what I m doing ->