“React Barcode Scanner” Kode Jawaban

Pemindai Barcode Bereaksi 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>
}

}
Inexpensive Ibis

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>    )  }}
Kind Kangaroo

Jawaban yang mirip dengan “React Barcode Scanner”

Pertanyaan yang mirip dengan “React Barcode Scanner”

Lebih banyak jawaban terkait untuk “React Barcode Scanner” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya