Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Posible rechazo de promesa no controlada (id: 0) react-native-text-recognition

Intenté agregar el método try / catch pero fue en vano, ¿tal vez lo agregué de manera incorrecta?


Objetivo : Abra la cámara y escanee una imagen en busca de texto, si tiene alguno, el texto se mostrará debajo de "Reconocimiento de texto".


El único lugar donde escribí el código fue en App.js:

 import React, {useEffect, useState} from 'react'; import { launchCamera, launchImageLibrary } from 'react-native-image-picker'; import TextRecognition from 'react-native-text-recognition'; import { SafeAreaView, StatusBar, Text, View, } from 'react-native'; const App = () => { const [image, setImage] = useState(null); const [text, setText] = useState(null); useEffect(() => { launchCamera({}, setImage); //launch camera (active) }, []); // useEffect(() => { // launchImageLibrary({}, setImage); //i can launch library using this // }, []); useEffect(() => { (async () => { if (image) { const result = await TextRecognition.recognize(image.assets[0].uri); console.log(result); setText(result); } })(); },[image]); return ( <SafeAreaView> <StatusBar> <View> <Text>Text Recognition</Text> {text ? <Text>{text}</Text> : null} </View> </StatusBar> </SafeAreaView> ); }; export default App;

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Intente envolver la await TextRecognition.recognize(...) con un intento/captura:

 useEffect(() => { (async () => { if (image) { try { const result = await TextRecognition.recognize(image.assets[0].uri); console.log(result); setText(result); } catch (error) { console.error(error); } } })(); },[image]);
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!