I'm trying to integrate barcode scanner in my app, i installed barcode library and did all the setup. When i run the app, camera is not opening. It getting black screen.
import {View, Text, StyleSheet, TouchableOpacity, FlatList} from 'react-native';
import React from 'react';
import HeaderMain from '../../../button/Header';
import Backnavigation from '../../../button/backbutton';
// @ts-ignore
import BarcodeScanner from 'react-native-scan-barcode';
const Addbook = ({navigation}:any) => {
const [torchMode, setTorchMode] = React.useState<string>('off');
const [cameraType, setCameraType] = React.useState<string>('back');
const barcodeReceived = (e:any) => {
console.log('Barcode: ' + e.data);
console.log('Type: ' + e.type);
};
return (
<View style={{flex: 1}}>
<BarcodeScanner
onBarCodeRead={barcodeReceived}
style={{ flex: 1 }}
torchMode={torchMode}
cameraType={cameraType}
/>
</View>
);
};
export default Addbook;
const styles = StyleSheet.create({
listHeader: {
width: '90%',
alignSelf: 'center',
backgroundColor: '#fff',
height: 50,
marginTop: 10,
justifyContent: 'center',
},
});