Answers for "react barcode scanner"

0

react barcode scanner

import React, { Component } from 'react'import BarcodeReader from 'react-barcode-reader' class Test extends Component {  constructor(props){    super(props)    this.state = {      result: 'No result',    }     this.handleScan = this.handleScan.bind(this)  }  handleScan(data){    this.setState({      result: data,    })  }  handleError(err){    console.error(err)  }  render(){     return(      <div>        <BarcodeReader          onError={this.handleError}          onScan={this.handleScan}          />        <p>{this.state.result}</p>      </div>    )  }}
Posted by: Guest on September-15-2021
0

barcode scanner react js

function BarcodeScanner (props) {

const [barcodeInputValue, updateBarcodeInputValue] = useState('')

function barcodeAutoFocus() {
    document.getElementById("SearchbyScanning").focus()
  }

  function onChangeBarcode(event) {
    updateBarcodeInputValue(event.target.value)
  }

  function onKeyPressBarcode(event) {
    if (event.keyCode === 13) {
      updateBarcodeInputValue(event.target.value)
    }
  }

return () {
            <div>
                <input
                  autoFocus={true}
                  placeholder='Start Scanning'
                  value={barcodeInputValue}
                  onChange={onChangeBarcode}
                  id='SearchbyScanning'
                  className='SearchInput'
                  onKeyDown={onKeyPressBarcode}
                  onBlur={barcodeAutoFocus}
                />
            </div>
}

}
Posted by: Guest on April-16-2021

Code answers related to "react barcode scanner"

Code answers related to "Javascript"

Browse Popular Code Answers by Language