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 React, { Component } from "react"; |
||||||
import QrReader from 'react-qr-scanner' |
import QrReader from "react-qr-reader"; |
||||||
|
|
||||||
export default class Scanner extends Component { |
export default class Scanner extends Component { |
||||||
constructor(props) { |
constructor(props) { |
||||||
super(props) |
super(props); |
||||||
this.state = { |
this.state = { |
||||||
delay: 100, |
delay: 100, |
||||||
result: '', |
result: "", |
||||||
} |
}; |
||||||
|
|
||||||
this.handleScan = this.handleScan.bind(this) |
this.handleScan = this.handleScan.bind(this); |
||||||
} |
} |
||||||
handleScan(data) { |
handleScan(data) { |
||||||
this.props.parent.setState({ |
this.props.parent.setState({ |
||||||
value: data, |
value: data, |
||||||
}) |
}); |
||||||
} |
} |
||||||
|
|
||||||
handleError(err) { |
handleError(err) { |
||||||
console.error(err) |
console.error(err); |
||||||
} |
} |
||||||
render() { |
render() { |
||||||
const previewStyle = { |
|
||||||
width: 320, |
|
||||||
borderRadius: '10px' |
|
||||||
} |
|
||||||
|
|
||||||
return ( |
return ( |
||||||
<> |
<> |
||||||
<QrReader |
<QrReader |
||||||
delay={this.state.delay} |
delay={300} |
||||||
style={previewStyle} |
|
||||||
onError={this.handleError} |
onError={this.handleError} |
||||||
onScan={this.handleScan} |
onScan={this.handleScan} |
||||||
legacyMode={true} |
style={{ width: "100%" }} |
||||||
facingMode={'user'} |
facingMode={this.props.parent.state.facingMode} |
||||||
/> |
/> |
||||||
</> |
</> |
||||||
) |
); |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue