Socket
Socket
Sign inDemoInstall

react-weblineindia-qrcode-scanner

Package Overview
Dependencies
11
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-weblineindia-qrcode-scanner

ReactJS based QR Code Scanner component, allowing you to detect and decode QR codes.


Version published
Weekly downloads
17
increased by88.89%
Maintainers
1
Install size
5.91 MB
Created
Weekly downloads
 

Readme

Source

ReactJS - QR Code / Barcode Scanner Component

ReactJS based QR Code Scanner component, allowing you to detect and decode QR codes.

Table of contents

  • Browser Support
  • Getting started
  • Usage
  • Available Props
  • Methods
  • Want to Contribute?
  • Collection of Components
  • Changelog
  • Credits
  • License
  • Keywords

Browser Support

ChromeFirefoxSafariEdgeIE
83.0 ✔77.0 ✔13.1.1 ✔83.0 ✔Not supported

Getting started

Install the npm package:

npm install react-weblineindia-qrcode-scanner
#OR
yarn add react-weblineindia-qrcode-scanner

Usage

Use the <react-weblineindia-qrcode-scanner> component:

import React, { Component } from 'react'
import QrReader from 'react-weblineindia-qrcode-scanner'

class Test extends Component {
  constructor(props){
    super(props)
    this.state = {
      delay: 100,
      result: 'No result',
    }

    this.handleScan = this.handleScan.bind(this)
  }
  handleScan(data){
    this.setState({
      result: data,
    })
  }
  handleError(err){
    console.error(err)
  }
  render(){
    const previewStyle = {
      height: 240,
      width: 320,
    }

    return(
      <div>
        <QrReader
          delay={this.state.delay}
          style={previewStyle}
          onError={this.handleError}
          onScan={this.handleScan}
          />
        <p>{this.state.result}</p>
      </div>
    )
  }
}

For Next.js Use dynamic import instead of usual import.


import dynamic from 'next/dynamic'
const QrReader = dynamic(() => import('react-weblineindia-qrcode-scanner').then((a) => a.QrReader), {ssr: false});

Available Props

PropTypedefaultDescription
delaynumber500The delay between scans in milliseconds. To disable the interval pass in false.
facingModestringSpecify which camera direction should be used (if available). Options: front and rear.
legacyModebooleanfalseIf the device does not allow camera access (e.g. IOS Browsers, Safari) you can enable legacyMode to allow the user to take a picture (On a mobile device) or use an existing one. To trigger the image dialog just call the method openImageDialog from the parent component. Warning You must call the method from a user action (eg. click event on some element).
maxImageSizenumber1500If legacyMode is active then the image will be downscaled to the given value while keepings its aspect ratio. Allowing larger images will increase the accuracy but it will also slow down the processing time.
styleobjectStyling for the preview element. This will be a video or an img when legacymode is true. Warning The preview will keep its aspect ratio, to disable this set the CSS property objectFit to fill.
classNamestringClassName for the container element.
chooseDeviceIdfunctionCalled when choosing which device to use for scanning. By default chooses the first video device matching facingMode, if no devices match the first video device found is choosen.

Methods

NameDescription
onScanScan event handler. Called every scan with the decoded value or null if no QR code was found.
onErrorFunction to call when an error occurs such as:- Not supported platform -The lack of available devices
onLoadCalled when the component is ready for use.
onImageLoadCalled when the image in legacyMode is loaded.

Want to Contribute?

  • Created something awesome, made this code better, added some functionality, or whatever (this is the hardest part).
  • Fork it.
  • Create new branch to contribute your changes.
  • Commit all your changes to your branch.
  • Submit a pull request.

Collection of Components

We have built many other components and free resources for software development in various programming languages. Kindly click here to view our Free Resources for Software Development


Changelog

Detailed changes for each release are documented in CHANGELOG.md.

Credits

react-weblineindia-qrcode-scanner is inspired by react-qr-scanner.

License

MIT

Keywords

react-weblineindia-qrcode-scanner, qrcode, qrcode-reader, qrcode-scanner, webrtc, react-qrcode-scanner, barcode-scanner, react-barcode, reactjs-qr-code, reactjs-barcode

Keywords

FAQs

Last updated on 30 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc