Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

221
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda