Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* eslint-disable react/jsx-props-no-spreading */
- import React from 'react';
- import PropTypes from 'prop-types';
- import { RNCamera } from 'react-native-camera';
- const RNCameraAndroid = ({ callback, children, ...props }) => {
- const barcodeHandler = ({ barcodes }) => {
- if (barcodes.length === 0) {
- return;
- }
- callback(barcodes[0].data);
- };
- return (
- <RNCamera
- // By default the RNCamera uses the old code detection on Android when using onBarCodeRead,
- // therefore we need to configure it to use MLKit to get better performance.
- onGoogleVisionBarcodesDetected={barcodeHandler}
- googleVisionBarcodeType={RNCamera.Constants.GoogleVisionBarcodeDetection.BarcodeType.QR_CODE}
- {...props}>
- {children}
- </RNCamera>
- );
- };
- RNCameraAndroid.propTypes = {
- callback: PropTypes.func.isRequired,
- children: PropTypes.node,
- };
- RNCameraAndroid.defaultProps = {
- children: null,
- };
- export default RNCameraAndroid;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement