OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

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

  • Thread starter Thread starter YAKUP KOK
  • Start date Start date
Y

YAKUP KOK

Guest
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:

Code:
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:

Code:
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

<p>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.</p>
<ol>
<li>TypeError: Cannot read property 'setEnabled' of null
When attempting to use the useZebraScanner hook and accessing the setEnabled function, I'm encountering this error:</li>
</ol>
<p><code>const { setEnabled } = useZebraScanner(handleScan);</code>
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:</p>
<pre><code>const handleScan = useCallback((code: string, scannerId: number) => { console.log(Scanned: ${code}); setBarcode(code); }, []);
</code></pre>
<p>3. Block-scoped variable 'handleScan' used before its declaration.ts(2448)Even after defining the handleScan function, I'm still encountering this error:</p>
<pre><code>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]);
</code></pre>
<p><a href="https://github.com/intellidev1991/react-native-scanner-zebra-enhanced" rel="nofollow noreferrer">https://github.com/intellidev1991/react-native-scanner-zebra-enhanced</a></p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top