react-native-image-editor icon indicating copy to clipboard operation
react-native-image-editor copied to clipboard

Cannot read Propery 'cropImage' of undefined

Open rjtubera opened this issue 5 years ago • 7 comments
trafficstars

Cannot read Propery 'cropImage' of undefined

Hi anyone, can help me, I'm having an error. All of my data is present. I don't know why i'm getting this error

import ImageEditor from "@react-native-community/image-editor";

               let cropData={
                    offset: {x: 0,y: 0},
                    size: {width: result.width,height: result.height},
                    displaySize: {width: 100,height: 100},
                    resizeMode: "contain"
                };
                ImageEditor.cropImage(result.uri,cropData).then(url => {
                    console.log("Cropped image uri",url);
                })

//result.uri has data //cropData has data as well

Any ideas, thanks

rjtubera avatar Jul 15 '20 14:07 rjtubera

i have the same problem.

fengmiaorxiaobai avatar Aug 28 '20 08:08 fengmiaorxiaobai

I have the same problem, too.

yutasb avatar Sep 01 '20 11:09 yutasb

Hi guys any update? I temporarily removed this snippet to make my app work.

rjtubera avatar Sep 01 '20 12:09 rjtubera

i have the same problem.

MrKernelPanic-dev avatar Oct 07 '20 13:10 MrKernelPanic-dev

Has anyone solved this yet? I have the same problem. It seems that cropImage calls RNCImageEditor.cropImage, and RNCImage is not defined.

senyangjiang avatar Nov 17 '20 05:11 senyangjiang

I solved this problem by directly using ImageEditingManager.cropImage in Native modules from react-native.

import { NativeModules } from "react-native";
const { ImageEditingManager } = NativeModules;
ImageEditingManager.cropImage(
      imageUri,
      cropData,
      (res) => {
        setCroppedUri(res);
      },
      (e) => {
        console.log(e);
      }

ImageEditingManager.cropImage takes four arguments: imageuri, cropData(same structure), resolve func, reject func I'm using react-native version 0.63

senyangjiang avatar Nov 17 '20 06:11 senyangjiang

Two years later, same problem. Using the NativeModules ImageEditingManager does seem to work though (at least on iOS — haven't tried on Android yet), so thank you for providing that solution.

adamtsai1 avatar Sep 16 '22 16:09 adamtsai1

Shouldn't be an issue if you are using the latest version

retyui avatar Feb 25 '24 13:02 retyui