I am trying to implement the expo-barcode-scanner, when I import the package in my component I am getting this error 'undefined is not an object (evaluating 'Object.keys(viewManagersMetadata)')', I am not familiar with this package... is there something I am missing here ?
I try to downgrade my expo version from 45 to 44, 43 and 42... I saw youtube videos with people using this package with older version, but it still gives me this error...
I tested only on the AndroidEmulator.
Error on Android Emulator ->
ScannBarcodeScreen.js
import React, { useEffect, useState } from "react";
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
import { BarCodeScanner } from 'expo-barcode-scanner';
const ScannBarcodeScreen = () => {
const [hasPermission, setHasPermission] = useState(null);
const [scanned, setScanned] = useState(false);
useEffect(() => {
(async () => {
const { status } = await BarCodeScanner.requestPermissionsAsync();
setHasPermission(status === 'granted');
})();
}, []);
const handleBarCodeScanned = ({ type, data }) => {
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={styles.container}>
<BarCodeScanner
onBarCodeScanned={scanned ? undefined : handleBarCodeScanned}
style={StyleSheet.absoluteFillObject}
/>
{scanned && <Button title={'Tap to Scan Again'} onPress={() => setScanned(false)} />}
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
camera: {
flex: 1,
},
buttonContainer: {
flex: 1,
backgroundColor: 'transparent',
flexDirection: 'row',
margin: 20,
},
button: {
flex: 0.1,
alignSelf: 'flex-end',
alignItems: 'center',
},
text: {
fontSize: 18,
color: 'white',
},
});
export default ScannBarcodeScreen;
package.json ( dependencies )
"dependencies": {
"@eva-design/eva": "^2.1.1",
"@expo-google-fonts/libre-barcode-128": "^0.2.2",
"@expo-google-fonts/montserrat": "^0.2.2",
"@expo/vector-icons": "^13.0.0",
"@react-native-community/checkbox": "^0.5.9",
"@react-native-firebase/app": "^14.0.1",
"@react-native-firebase/auth": "^14.0.1",
"@react-native-firebase/firestore": "^14.0.1",
"@react-native-firebase/messaging": "^14.0.1",
"@react-native-firebase/storage": "^14.0.1",
"@react-navigation/bottom-tabs": "^6.0.9",
"@react-navigation/native": "^6.0.6",
"@react-navigation/native-stack": "^6.2.5",
"@stripe/stripe-react-native": "0.6.1",
"@ui-kitten/components": "^5.1.1",
"@ui-kitten/eva-icons": "^5.1.1",
"big.js": "^6.1.1",
"eas-cli": "^0.50.0",
"expo": "^45.0.0",
"expo-app-loading": "~2.0.0",
"expo-barcode-scanner": "~11.3.0",
"expo-camera": "~12.2.0",
"expo-dev-client": "~0.9.6",
"expo-fast-image": "^1.1.3",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"expo-updates": "~0.13.1",
"jsbarcode": "^3.11.5",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-gesture-handler": "~2.2.1",
"react-native-image-slider-box": "^1.1.14",
"react-native-modal": "^13.0.0",
"react-native-paper": "^4.11.2",
"react-native-phone-number-input": "^2.1.0",
"react-native-qrcode-svg": "^6.1.2",
"react-native-reanimated": "~2.8.0",
"react-native-redash": "^16.2.3",
"react-native-safe-area-context": "4.2.4",
"react-native-screens": "~3.11.1",
"react-native-select-dropdown": "^1.13.0",
"react-native-svg": "12.3.0",
"react-native-swipe-modal-up-down": "^1.1.0",
"react-native-toast-message": "^2.1.1",
"react-native-vector-icons": "^9.0.0",
"react-native-view-slider": "^1.1.1",
"react-native-web": "0.17.7",
"referral-codes": "^2.0.1",
"tailwind-react-native-classnames": "^1.5.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@types/react": "~17.0.21"
}
