Код: Выделить всё
import React, { useState } from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';
import { CameraView, useCameraPermissions } from 'expo-camera';
import Screen from './Screen';
import TextHyperlink from '../components/TextHyperlink';
function ScannerScreen() {
const [scanned, setScanned] = useState(false);
const [result, setResult] = useState(null);
const [permission, requestPermission] = useCameraPermissions();
if (!permission) {
return ;
}
if (!permission.granted) {
return (
We need your permission to show the camera
);
}
const handleBarCodeScanned = ({ data }) => {
console.log('lalalalala');
if (data) {
setScanned(true);
setResult(data);
}
};
const handleResult = () => {
if (!result) return null;
if (result.startsWith('http')) {
return (
);
} else {
return {result};
}
};
return (
{scanned && (
setScanned(false)}
/>
)}
{handleResult()}
);
}
const styles = StyleSheet.create({
camerabox: {
flex: 1,
justifyContent: 'center',
width: '100%',
},
resultlink: {
color: 'blue',
flexWrap: 'wrap',
fontFamily: 'monospace',
padding: 20,
textDecorationLine: 'underline',
},
resulttext: {
color: 'white',
flexWrap: 'wrap',
fontFamily: 'monospace',
padding: 20,
},
textbox: {
borderTopColor: 'blue',
borderTopWidth: 3,
alignItems: 'center',
flex: 1,
justifyContent: 'center',
width: '100%',
},
});
export default ScannerScreen;
Код: Выделить всё
"expo": "~51.0.21"
"expo-camera": "^15.0.14"
"react-native": "0.74.3"
Дело в том, что мой код отлично работал с Экспо 50.
Подробнее здесь: https://stackoverflow.com/questions/787 ... ot-working