callstack / react-native-image-editor

A library providing an API for cropping images from the web and the local file system.
MIT License
378 stars 118 forks source link

Cannot read Propery 'cropImage' of undefined #72

Closed rjtubera closed 7 months ago

rjtubera commented 4 years ago

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

fengmiaorxiaobai commented 4 years ago

i have the same problem.

yutasb commented 4 years ago

I have the same problem, too.

rjtubera commented 4 years ago

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

MrKernelPanic-dev commented 4 years ago

i have the same problem.

senyangjiang commented 3 years ago

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

senyangjiang commented 3 years ago

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

adamtsai1 commented 2 years ago

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.

retyui commented 7 months ago

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