Android Question TypeError: Cannot read property 'setEnabled' of null, js engine: hermes

Status
Not open for further replies.

davidlawrence83

New Member
I'm trying to integrate a Zebra barcode scanner for a React Native application running on a Zebra mobile device. However, I'm encountering several issues that I need help with.

  1. TypeError: Cannot read property 'setEnabled' of null When attempting to use the useZebraScanner hook and accessing the setEnabled function, I'm encountering this error:
const { setEnabled } = useZebraScanner(handleScan); 2. Expected 2 arguments, but got 1.ts(2554) I'm getting the Expected 2 arguments, but got 1 TypeScript error when defining the handleScan function:

const handleScan = useCallback((code: string, scannerId: number) => { console.log(Scanned: ${code}); setBarcode(code); }, []);

3. Block-scoped variable 'handleScan' used before its declaration.ts(2448)Even after defining the handleScan function, I'm still encountering this error:

const [barcode, setBarcode] = useState<string | null>(null);
const { setEnabled } = useZebraScanner(handleScan);

const handleScan = useCallback((code: string, scannerId: number) => {
console.log(`Scanned: ${code}`);
setBarcode(code);
}, []);

const onPullTriggerScanning = useCallback(() => {
if (setEnabled) {
setEnabled(true);
} else {
console.error('setEnabled is not defined.');
}
}, [setEnabled]);

const onReleaseTriggerScanning = useCallback(() => {
if (setEnabled) {
setEnabled(false);
} else {
console.error('setEnabled is not defined.');
}
}, [setEnabled]);

https://github.com/intellidev1991/react-native-scanner-zebra-enhanced
Found a solution but don't know how it works .....
https://cloudswood.uk/
 
Status
Not open for further replies.
Top