react-qr-reader
A React Component for reading QR codes from the webcam
npm downloads npm version npm license
react-qr-reader유사 패키지:
npm 다운로드 트렌드
3 년
🌟 react-qr-reader의 README.md에 실시간 사용 차트를 표시하려면 아래 코드를 복사하세요.
## Usage Trend
[![Usage Trend of react-qr-reader](https://npm-compare.com/img/npm-trend/THREE_YEARS/react-qr-reader.png)](https://npm-compare.com/react-qr-reader#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 react-qr-reader의 README.md에 GitHub Stars 트렌드 차트를 표시하려면 아래 코드를 복사하세요.
## GitHub Stars Trend
[![GitHub Stars Trend of react-qr-reader](https://npm-compare.com/img/github-trend/react-qr-reader.png)](https://npm-compare.com/react-qr-reader)
통계 세부사항
패키지
다운로드
Stars
크기
Issues
발행일
라이선스
react-qr-reader248,7341,1584.38 MB152-MIT
react-qr-reader의 README

React QR Reader npm version License: MIT Known Vulnerabilities

:rocket: React QR Reader component. Check out the demo.

Table of contents

Use Case

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

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 >= 16.8.0.

Installation

You can install this library via NPM or YARN.

NPM

npm i react-qr-reader

YARN

yarn add react-qr-reader

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 = (props) => {
  const [data, setData] = useState('No result');

  return (
    <>
      <QrReader
        onResult={(result, error) => {
          if (!!result) {
            setData(result?.text);
          }

          if (!!error) {
            console.info(error);
          }
        }}
        style={{ width: '100%' }}
      />
      <p>{data}</p>
    </>
  );
};

Component API

The QrReader component has the following props:

| Properties | Types | Default Value | Description | | ------------------- | ----------------------------------------------------------------------------------------------- | ------------------------ | -------------------------------------------------------- | | constraints | MediaTrackConstraints | { facingMode: 'user' } | Specify which camera should be used (if available). | | onResult | function | none | Scan event handler | | videoId | string | video | The ID for the video element | | scanDelay | number | 500 | The scan period for the QR hook | | ViewFinder | component | none | ViewFinder component to rendering over the video element | | className | string | none | ClassName for the container element. | | containerStyle | object | none | Style object for the container element. | | videoContainerStyle | object | none | Style object for the video container element. | | videoStyle | object | none | Style object for the video element. |

Browser Support

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

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.