Skip to content

Commit 721d5ba

Browse files
committed
Fixed hook to return proper function
1 parent 4eb04ad commit 721d5ba

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-scanner-zebra",
33
"title": "React Native Scanner Zebra",
4-
"version": "0.1.2",
4+
"version": "0.1.3",
55
"description": "React Native module for Zebra barcode scanners",
66
"homepage": "https://github.com/crypton-tech/react-native-scanner-zebra#readme",
77
"baseUrl": "https://github.com/crypton-tech/react-native-scanner-zebra",

src/index.tsx

+10-12
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@ const supportedEvents = [
3030
'scanner-disconnected',
3131
]
3232

33+
const setEnabled = (isEnabled: boolean) => {
34+
NativeModules.ZebraScanner.setEnabled(isEnabled)
35+
}
36+
37+
const getActiveScanners = (callback: CallbackScanners) => {
38+
NativeModules.ZebraScanner.getActiveScanners((scanners: Scanner[]) => {
39+
callback(scanners)
40+
})
41+
}
42+
3343
const useZebraScanner = (
3444
onScan: EventBarcodeHandler,
3545
onEvent: EventHandler | undefined
3646
) => {
3747
useLayoutEffect(() => {
3848
const handleEvent = (data: EventBarcode) => {
39-
console.log('Event: Barcode', data)
4049
if (onScan) {
4150
onScan(data.barcode || '', data.id)
4251
}
@@ -49,7 +58,6 @@ const useZebraScanner = (
4958
supportedEvents.forEach((event: string) => {
5059
listeners.push(
5160
RNZebraScanner.addListener(event, (data) => {
52-
console.log('Event:', event, data)
5361
onEvent(event, data.id || '')
5462
})
5563
)
@@ -63,16 +71,6 @@ const useZebraScanner = (
6371
}
6472
})
6573

66-
const setEnabled = (isEnabled: boolean) => {
67-
NativeModules.ZebraScanner.setEnabled(isEnabled)
68-
}
69-
70-
const getActiveScanners = (callback: CallbackScanners) => {
71-
NativeModules.ZebraScanner.getActiveScanners((scanners: Scanner[]) => {
72-
callback(scanners)
73-
})
74-
}
75-
7674
return {
7775
setEnabled,
7876
getActiveScanners,

0 commit comments

Comments
 (0)