react-simple-qr-code-scanner
Advanced tools
Comparing version 1.0.3 to 1.5.0
{ | ||
"name": "react-simple-qr-code-scanner", | ||
"version": "1.0.3", | ||
"version": "1.5.0", | ||
"description": "A super simple qr code scanner", | ||
@@ -8,3 +8,4 @@ "main": "index.js", | ||
"clean": "rm -rf dist", | ||
"build": "yarn clean && tsc && cp package.json README.md ./dist" | ||
"build": "yarn clean && tsc && cp package.json README.md ./dist", | ||
"publishToNpm": "npm publish ./dist" | ||
}, | ||
@@ -11,0 +12,0 @@ "repository": { |
/// <reference types="react" /> | ||
import { Exception, Result } from "@zxing/library"; | ||
declare type props = { | ||
result?: (result: Result) => void; | ||
errors?: (error: Exception) => void; | ||
onResult: (result: Result) => void; | ||
Errors?: (error: Exception) => void; | ||
facingMode?: "enviroment" | "user"; | ||
}; | ||
export declare const QrCodeScanner: (props: props) => JSX.Element; | ||
export {}; |
@@ -13,9 +13,9 @@ import { BrowserMultiFormatReader } from "@zxing/library"; | ||
video: { | ||
facingMode: "enviroment", | ||
facingMode: props.facingMode || "enviroment", | ||
}, | ||
}, videoRef.current, (result, error) => { | ||
if (result && props.result != null) | ||
props.result(result); | ||
if (error && props.errors != null) | ||
props.errors(error); | ||
if (result) | ||
props.onResult(result); | ||
if (error && props.Errors != null) | ||
props.Errors(error); | ||
}); | ||
@@ -22,0 +22,0 @@ return () => { |
# A simple qr-code scanner for react | ||
This is a simple qr-code scanner component for react | ||
## Installing | ||
A step by step series guide to setup this component. | ||
Start a node project | ||
npm init | ||
Install the library with composer | ||
npm i react-simple-qr-code-scanner | ||
### Demo | ||
```tsx | ||
import { QrCodeScanner } from "react-simple-qr-code-scanner"; | ||
function App() { | ||
return ( | ||
<QrCodeScanner | ||
onResult={(result) => { | ||
console.log(result); | ||
}} | ||
Errors={(error) => { | ||
//console.log(error); | ||
}}, | ||
facingMode={"enviroment"} //or user | ||
/> | ||
); | ||
} | ||
``` | ||
## License | ||
This project is licensed under the [MIT](LICENSE) | ||
License - see the [LICENSE](LICENSE) file for | ||
details |
2928
38
41