1.0.3 • Published 4 years ago

react-qr-fast-reader v1.0.3

Weekly downloads
9
License
MIT
Repository
github
Last release
4 years ago

react-qr-fast-reader

Faster qr reader implementation library than react-qr-reader using jsQR to decode images

React QR Reader License: MIT

Install

You can install this library via NPM or YARN.

NPM

npm i react-qr-fast-reader

YARN

yarn add react-qr-fast-reader

Usage

The usage is really simple:

import React, { useState } from 'react';
import { QrReader } from 'react-qr-fast-reader';

const Test = (props) => {
  const [data, setData] = useState('No result');

  const handleScan = (data) => {
    if (data) {
      setData(data);
    }
  };

  const handleError = (err) => console.error(err);

  return (
    <>
      <QrReader
        onScan={handleScan}
        onError={handleError}
        style={{ width: '100%' }}
      />
      <p>{data}</p>
    </>
  );
};

Props

Events

PropArgumentDescription
onScanresultScan event handler. Called every scan with the decoded value or null if no QR code was found.
onErrorErrorCalled when an error occurs.
onLoadobjectCalled when the component is ready for use. Object properties are stream: MediaStream

Options

PropTypeDefaultDescription
facingModeuser or environmentenvironmentSpecify which camera should be used (if available).
resolutionnumber600The resolution of the video (or image in legacyMode). Larger resolution will increase the accuracy but it will also slow down the processing time.
stylea valid React stylenoneStyling for the container element. Warning The preview will always keep its 1:1 aspect ratio.
classNamestringnoneClassName for the container element.
showViewFinderbooleantrueShow or hide the build in view finder. See demo
constraintsobjectnullUse custom camera constraints that the override default behavior. MediaTrackConstraints
debugbooleannullEnable debug logs to see what's going on inside the component
viewFinderColorstring'rgba(255, 0, 0, 0.5)'Change viewFinder color for SVG Path
viewFinderStrokeWidthstring'5'Change viewFinder width for SVG Path

Tested platforms

  • Chrome Mac OS & Android
  • Firefox Mac OS & Android
  • Safari Mac OS & IOS

Issues

Please, open an issue following one of the issues templates. We will do our best to fix them.

Contributing

If you want to contribute to this project see contributing for more information.

License

Distributed under the MIT license. See LICENSE for more information.

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago