Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda