Skip to content

Sensorfactdev/qr-code-scanner

Repository files navigation

QR Code Scanner

Build Status Known Vulnerabilities npm version Package Quality

Usage

import QrCodeScanner from '@sensorfactdev/qr-code-scanner';

const handleScanResult = result => {
  console.log(result);
  // {
  //   "result": "RESULT STRING VALUE",
  //   "points": [
  //     {
  //       "x": 171,
  //       "y": 445,
  //       "count": 2,
  //       "estimatedModuleSize": 3.857142857142857
  //     },
  //     // .... more points
  //   ]
  // }
}

const MyApp = () => (
  <div>
    <QrCodeScanner
      onQrCodeScanned={handleScanResult}
      width={window.innerWidth}
      height={window.innerHeight}
      showAimAssist // Defaults to true, disable to remove the aim assist
    />
  </div>
)

Props

Key Type Default Value
onQrCodeScanned Function console.log
width Number window.innerWidth
height Number window.innerHeight

Development

To start Storybook:

yarn start

To run the tests:

yarn test

To run tests in watch mode:

yarn test --watch

Building the module

yarn build