2.3.13 • Published 1 month ago

react-qrcode-reader v2.3.13

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

react-qrcode-reader

QRCode Reader for modern React

install

$ npm i react-qrcode-reader

how to use

1. with onRead

import React from 'react';

import QrCodeReader, { QRCode } from 'react-qrcode-reader';

export function App() {
  const [val, setVal] = React.useState<string>('');

  const handleRead = (code: QRCode) => {
    setVal(code.data);
  };

  return (
    <>
      <QrCodeReader delay={100} width={500} height={500} onRead={handleRead} />
      <p>{val}</p>
    </>
  );
}

2. with setter for hook

import React from 'react';

import QrCodeReader, { QRCode } from 'react-qrcode-reader';

export function App() {
  const [val, setVal] = React.useState<string>('');

  return (
    <>
      <QrCodeReader delay={100} width={600} height={500} action={setVal} />
      <p>{val}</p>
    </>
  );
}

API

<QrCodeReader> has 3 required props and 3 optional props.

proptypeinstructiondefault
delaynumberdelay of recapture
widthnumberwidth of image
heightnumberheight of image
onRead(QRCode) => voidcallback on read qrcodenone
action(string) => voidaction on read qrcodenone
videoConstraintsobjectMediaStreamConstraints(s) for the videonone

argument of onRead is QRCode data. QRCode is interface in jsQR.

argument of action is the string included in QRCode. You can simply get value of QRCode by this.

argument of videoConstraints is the object included in Webcam. We can build a constraints object by passing it to the videoConstraints prop. Please take a look at the MDN docs to get an understanding how this works: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

Version Up

Read doc for update 1 to 2.

2.3.13

1 month ago

2.3.12

4 months ago

2.3.11

7 months ago

2.3.10

8 months ago

2.3.0

9 months ago

2.2.1

9 months ago

2.2.0

9 months ago

2.1.1

9 months ago

2.0.2

11 months ago

2.3.2

9 months ago

2.3.1

9 months ago

2.3.4

9 months ago

2.3.3

9 months ago

2.3.6

9 months ago

2.3.5

9 months ago

2.1.0

9 months ago

2.0.1

11 months ago

2.3.8

8 months ago

2.3.9

8 months ago

1.1.3

1 year ago

2.0.0

1 year ago

1.1.1

1 year ago

1.1.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

3 years ago