parent
							
								
									5ebdff6f92
								
							
						
					
					
						commit
						9368cfcf96
					
				
				 8 changed files with 110 additions and 53 deletions
			
			
		
									
										Binary file not shown.
									
								
							
						@ -1,42 +1,36 @@ | 
				
			||||
import React, { Component } from 'react' | 
				
			||||
import QrReader from 'react-qr-scanner' | 
				
			||||
import React, { Component } from "react"; | 
				
			||||
import QrReader from "react-qr-reader"; | 
				
			||||
 | 
				
			||||
export default class Scanner extends Component { | 
				
			||||
  constructor(props) { | 
				
			||||
    super(props) | 
				
			||||
    super(props); | 
				
			||||
    this.state = { | 
				
			||||
      delay: 100, | 
				
			||||
      result: '', | 
				
			||||
    } | 
				
			||||
      result: "", | 
				
			||||
    }; | 
				
			||||
 | 
				
			||||
    this.handleScan = this.handleScan.bind(this) | 
				
			||||
    this.handleScan = this.handleScan.bind(this); | 
				
			||||
  } | 
				
			||||
  handleScan(data) { | 
				
			||||
    this.props.parent.setState({ | 
				
			||||
      value: data, | 
				
			||||
    }) | 
				
			||||
    }); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  handleError(err) { | 
				
			||||
    console.error(err) | 
				
			||||
    console.error(err); | 
				
			||||
  } | 
				
			||||
  render() { | 
				
			||||
    const previewStyle = { | 
				
			||||
      width: 320, | 
				
			||||
      borderRadius: '10px' | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    return ( | 
				
			||||
      <> | 
				
			||||
        <QrReader | 
				
			||||
          delay={this.state.delay} | 
				
			||||
          style={previewStyle} | 
				
			||||
          delay={300} | 
				
			||||
          onError={this.handleError} | 
				
			||||
          onScan={this.handleScan} | 
				
			||||
          legacyMode={true} | 
				
			||||
          facingMode={'user'} | 
				
			||||
          style={{ width: "100%" }} | 
				
			||||
          facingMode={this.props.parent.state.facingMode} | 
				
			||||
        /> | 
				
			||||
      </> | 
				
			||||
    ) | 
				
			||||
    ); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue