You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
700 B
36 lines
700 B
import React, { Component } from "react"; |
|
import QrReader from "react-qr-reader"; |
|
|
|
export default class Scanner extends Component { |
|
constructor(props) { |
|
super(props); |
|
this.state = { |
|
delay: 100, |
|
result: "", |
|
}; |
|
|
|
this.handleScan = this.handleScan.bind(this); |
|
} |
|
handleScan(data) { |
|
this.props.parent.setState({ |
|
value: data, |
|
}); |
|
} |
|
|
|
handleError(err) { |
|
console.error(err); |
|
} |
|
render() { |
|
return ( |
|
<> |
|
<QrReader |
|
delay={300} |
|
onError={this.handleError} |
|
onScan={this.handleScan} |
|
style={{ width: "100%" }} |
|
facingMode={this.props.parent.state.facingMode} |
|
/> |
|
</> |
|
); |
|
} |
|
}
|
|
|