agoldis / react-native-mlkit-ocr

Google on-device MLKit Text Recognition for React Native
MIT License
176 stars 41 forks source link

Cannot read property 'detectFromUri' of undefined #9

Closed hayr-hotoca closed 3 years ago

hayr-hotoca commented 3 years ago

import MlkitOcr from 'react-native-mlkit-ocr';

const resultFromUri = await MlkitOcr.detectFromUri(data.uri);

I tried to build through xcode and run again in my iPhone 6 but still having issue

Xcode 10.3 "react": "16.8.3", "react-dom": "16.8.3", "react-native": "0.59.10", "react-native-mlkit-ocr": "^0.2.2",

device: IPhone 6

hayr-hotoca commented 3 years ago

ooh there is an example let me try it then

CarlosMayoralMX commented 3 years ago

Data should be a ImagePickerResponse type, and according definition you should use data.assets[0].uri, you coould check if make a console.log(response) right after the async function:

async (response: ImagePickerResponse) => { console.log(response.assets[0].uri) if (!response.assets[0].uri) { throw new Error('oh!'); } try { setImage(response); setResult(await MlkitOcr.detectFromUri(response.assets[0].uri)); } catch (e) { console.error(e); } }