qrscan

1.0.6 • Public • Published

qrscan

QR scanner for React

See a simple demo here.

Installation and usage

First, install the component from npm.

yarn add qrscan

Then, use it in your app.

import React, { Component } from 'react'
import QRScan from 'qrscan'
 
class App extends Component {
  
  constructor (props) {
    super(props)
    this.state = { value: '', watching: false }
    this.onFind = this.onFind.bind(this)
  }
  
  onFind (value) {
    this.setState({ value, watching: false })
  }
  
  render () {
    return (
      <Fragment>
        <h1>QRScan Demo</h1>
        {this.state.watching
          ? (
            <QRScan onFind={this.onFind} />
          )
          : (
            <Fragment>
              <button onClick={() => this.setState({ watching: true })}>Scan</button>
              <h4>value: {this.state.value}</h4>
            </Fragment>
          )
        }
      </Fragment>
    )
  }
}

Props

The QRScan component takes as props:

  • onFind - subscribe to qr code detection

Readme

Keywords

none

Package Sidebar

Install

npm i qrscan

Weekly Downloads

51

Version

1.0.6

License

MIT

Unpacked Size

847 kB

Total Files

15

Last publish

Collaborators

  • louismerlin