npm

@codesaursx/react-scanner
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@CodesaursX/react-scanner

A React component to read QR and Barcodes in web-applications.

Installation

npm install @CodesaursX/react-scanner --save
# or
yarn add @CodesaursX/react-scanner

Usage

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>
  );
};

Contributing

Contributions are always welcome, please open an issue first. :)

License

MIT

Package Sidebar

Install

npm i @codesaursx/react-scanner

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

20.5 kB

Total Files

12

Last publish

Collaborators

  • andrescptrc
  • armandocaslop
  • angel.codes