0.2.7 • Published 7 months ago

@memenashi/react-qr-reader v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

1. React QR Reader

Attention!!!!

This repository and library is fork from here https://github.com/JodusNodus/react-qr-reader

Table of contents

1. Use Case

You need a component for Scanning QR codes from a web browser based app.

2. Compatibility

This component has been tested in the following browsers:

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

Since this library does internal use of hooks you need React >= 18.2.0.

3. Installation

You can install this library via NPM or YARN.

3.1. NPM

npm i react-qr-reader

3.2. YARN

yarn add react-qr-reader

4. Example Usage

After reading and performing the previous steps, you should be able to import the library and use it like in this example:

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

const Test = () => {
  const [error, setError] = useState('');
  const [data, setData] = useState('');

  return (
    <div style={styles.container}>
      <QrReader
        {...args}
        onResult={(result, error) => {
          if (result) {
            setData(result.getText());
          }

          if (error) {
            setError(error.message);
          }
        }}
      />
      <p>The value is: {JSON.stringify(data, null, 2)}</p>
      <p>The error is: {error}</p>
    </div>
  );
};

5. Component API

The QrReader component has the following props:

PropertiesTypesDefault ValueDescription
constraintsMediaTrackConstraints{ facingMode: 'user' }Specify which camera should be used (if available).
onResultfunctionnoneScan event handler
videoIdstringvideoThe ID for the video element
scanDelaynumber500The scan period for the QR hook
ViewFindercomponentnoneViewFinder component to rendering over the video element
classNamestringnoneClassName for the container element.
containerStyleobjectnoneStyle object for the container element.
videoContainerStyleobjectnoneStyle object for the video container element.
videoStyleobjectnoneStyle object for the video element.

6. Maintainers

7. Browser Support

If you need to support older browsers, checkout this guide in how to make it compatible with legacy ones

0.2.1

8 months ago

0.1.2

8 months ago

0.2.0

8 months ago

0.1.1

8 months ago

0.2.7

7 months ago

0.2.6

7 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.1.0

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago