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

220
Views
Why Expo-barcode-scanner app crash without output?

There is a separate page in the app where I have posted expo-barcode-scanner. The bottom line is that when you open this particular page, on which the camera is located, the application immediately crashes. No errors are printed to the console. The code of the scanner itself was taken from off. documentation.

Wherein:

  • It doesn't matter if I do it through the "Camera" component or through the "BarCodeScanner" component, it still crashes
  • If you pass in onBarcodeScanned = undefined, then the camera itself works and starts, but as soon as onBarcodeScanned = handleBarCodeScanned - the program immediately crashes.
const AdminScreen = ({navigation}) => {
  const [hasPermission, setHasPermission] = useState(null);
  const [scanned, setScanned] = useState(true);
  const [cameraReady, setCameraReady] = useState(false);

  useEffect(() => {
    (async () => {
      const { status } = await BarCodeScanner.requestPermissionsAsync();
      setHasPermission(status === 'granted');
    })();
  }, []);
  
  const onCameraReady = () => {
    setCameraReady(true)
    console.warn("Camera ready")
  }

  const handleBarCodeScanned = ({ type, data }) => {
    if (cameraReady){
      setScanned(true);
      alert(`Bar code with type ${type} and data ${data} has been scanned!`);
    }
  };

  if (hasPermission === null) {
    return <Text>Requesting for camera permission</Text>;
  }
  if (hasPermission === false) {
    return <Text>No access to camera</Text>;
  }

  return (
    <View
    style={{
      flex: 1,
      resizeMode: 'cover',
    }}>
      <Camera
        onCameraReady={onCameraReady}
        barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
        onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
        style={{
          flex:1
        }}
      />
      {scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}
    </View>
  );
}

P.S: I do not exclude that the error is as obvious and stupid as possible, I started learning react and js just a week ago, I can easily miss something

about 4 years ago · Juan Pablo Isaza
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!