barcode-react-scanner
v1.2.0
Published
react component to scan barcode
Downloads
724
Maintainers
Readme
barcode-react-scanner
Is a simple react component to read barcodes.
How to use ?
Install
Recommended way to install is by using package manager (npm, yarn etc):
npm i barcode-react-scanner
or
yarn add barcode-react-scanner
Use
import React, { useState } from 'react';
import BarCodeScanner from 'barcode-react-scanner';
const TestingComponent = (): JSX.Element => {
const [code, setCode] = useState<string>('')
return (
<>
{ code && <p> code </p> }
<BarCodeScanner onUpdate={ (err, resp): void => {
if(resp) {
setCode(resp.getText())
}
}}
/>
</>
);
}
export default TestingComponent;