A React component to read QR and Barcodes in web-applications.
npm install @codesaursx/react-scanner --save
# or
yarn add @codesaursx/react-scanner
Once you install the package, you can import the component and use it as follow:
import { useState } from 'react';
import { Scanner } from '@codesaursx/react-scanner';
const App = () => {
const [code, setCode] = React.useState('');
return (
<div>
<Scanner
width="400px"
height="400px"
delay={2000}
onUpdate={(e, data) => {
if (data) {
console.log(data);
setCode(data.getText());
}
}}
/>
<p>result: {code}</p>
</div>
);
};
Contributions are always welcome, please open an issue first. :)