1.0.6 • Published 6 years ago

qrscan v1.0.6

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago