question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useBarcodeRead hook is not working

See original GitHub issue

Hi there,

I am trying to use the useBarcodeRead hook, but it is not triggering anything. I have created a pretty simple camera component.

import React from 'react';
import { StyleSheet, View } from 'react-native';
import { RNCamera } from 'react-native-camera';
import {
  BarcodeMaskWithOuterLayout,
  useBarcodeRead,
} from '@nartc/react-native-barcode-mask';

import { getColor } from '../assets/style/style.constants';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    flexDirection: 'column',
  },
  preview: {
    flex: 1,
    justifyContent: 'flex-end',
    alignItems: 'center',
  },
});
export const Camera = () => {
  const {
    barcodeRead,
    onBarcodeRead,
    onBarcodeFinderLayoutChange,
  } = useBarcodeRead(
    true,
    barcodeData => {
      console.log(barcodeData);
      return barcodeData;
    },
    processedBarcodeData => {
      console.log(processedBarcodeData);
      return processedBarcodeData;
    },
  );
  console.log(1, barcodeRead);
  console.log(2, onBarcodeRead);
  console.log(3, onBarcodeFinderLayoutChange);

  return (
    <View style={styles.container}>
      <RNCamera
        barCodeTypes={barcodeRead ? [] : [RNCamera.Constants.BarCodeType.qr]}
        onBarCodeRead={onBarcodeRead}
        captureAudio={false}
        style={styles.preview}
        type={RNCamera.Constants.Type.back}
      >
        <BarcodeMaskWithOuterLayout
          edgeColor={getColor().PRIMARY}
          animatedLineColor={getColor().PRIMARY}
          maskOpacity={0.7}
          height="80%"
          width="80%"
          showAnimatedLine
          onLayoutChange={onBarcodeFinderLayoutChange}
        />
      </RNCamera>
    </View>
  );
};

The console.log are not being triggered. Am I doing something wrong or is there something wrong with the lib?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:31 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
MakhouTcommented, Feb 11, 2020

Hi @nartc Sorry due sickness I wasn’t able to test it yet. I’m back at the office today, I’ll try to test it this week ASAP and will get back to you.

1reaction
nartccommented, Jan 8, 2020

Thanks for the information

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do i solve this Hook error in React Native? - Stack Overflow
Im Trying to make this app as a Project because i just learned React Native and i've gotten this far without problems but...
Read more >
BarcodeMask Component for RNCamera - Morioh
To use this feature, you need to import and use useBarcodeRead custom hook: const { barcodeRead, onBarcodeRead, onBarcodeFinderLayoutChange, } = useBarcodeRead( ...
Read more >
Automationproduction systems and cim groover - Academia.edu
Complexity of cyclic scheduling problems: A state-of-the-art survey ... nut much of the hook was very similar to the 191';0lex I. By the...
Read more >
Introduction to Material Handling - IE473
Problem. Solutions,' paper presented at the MHI 1994 Imanafionll/. Research Colloquium. Grand ... from the trolleys are hooks, baskets, or other receptacles.
Read more >
Shop Vehicles Scanner with great discounts and prices online - Aug ...
... Engine Auto Diagnostic Reset Tool V301 Use Barcode Read Information ... for Android Devices Bluetooth Obd2 Scanner W/cd Driver for Most 1996 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found