Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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>    )  }}
Comment

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>
}

}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js object to c# object 
Javascript :: how to add attribute in a element 
Javascript :: javascript detect when youtube video ends 
Javascript :: javascript identifiers 
Javascript :: react native skeleton 
Javascript :: get number right of the dot length javascript 
Javascript :: typescript jsdoc interface 
Javascript :: js background color 
Javascript :: create canvas p5 
Javascript :: download file using javascript 
Javascript :: react array if id is present do not add element 
Javascript :: reverse string 
Javascript :: what is syntactic sugar javascript 
Javascript :: Number of trailing zeros of N! 
Javascript :: lodash groupby return array 
Javascript :: how to fetch data redux 
Javascript :: js spread parameters 
Javascript :: how to parse header in node.js lambda 
Javascript :: change icon on click angular 
Javascript :: angular.json 
Javascript :: js data types 
Javascript :: circular queue in javascript 
Javascript :: npx vs npm 
Javascript :: async.each javascript 
Javascript :: path object d3.js 
Javascript :: dynamodb json to regular json 
Javascript :: react navigation header title 
Javascript :: use navigation in class component react native drawer navigation 
Javascript :: pure function 
Javascript :: json date format 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =