New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-simple-qr-code-scanner

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-qr-code-scanner - npm Package Compare versions

Comparing version 1.5.1 to 2.0.0-beta.1

dist/index.d.mts

38

package.json
{
"name": "react-simple-qr-code-scanner",
"version": "1.5.1",
"version": "2.0.0-beta.1",
"description": "A super simple qr code scanner",
"main": "index.js",
"exports": {
".": {
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"clean": "rm -rf dist",
"build": "yarn clean && tsc && cp package.json README.md ./dist",
"publishToNpm": "npm publish ./dist"
"build": "tsup"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mitchellston/qr-code-scanner"
},
"files": [
"dist",
"LICENSE",
"README.md"
],
"keywords": [

@@ -25,2 +29,6 @@ "react",

],
"repository": {
"type": "git",
"url": "git+https://github.com/mitchellston/qr-code-scanner"
},
"author": {

@@ -34,10 +42,16 @@ "name": "Mitchellston"

"devDependencies": {
"@types/react": "^17.0.52",
"@types/react": "^17.0.62",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.8.4"
"tsup": "^7.1.0",
"typescript": "^4.9.5"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"dependencies": {
"@zxing/library": "^0.19.1"
"@zxing/library": "^0.19.3",
"superjson": "^1.12.4"
}
}

@@ -17,3 +17,3 @@ # A simple qr-code scanner for react

### Demo
### Basic demo

@@ -25,9 +25,9 @@ ```tsx

<QrCodeScanner
onResult={(result) => {
onResult={(result, rawResult) => {
console.log(result);
}}
Errors={(error) => {
//console.log(error);
console.log(error);
}},
facingMode={"enviroment"} //or user
facingMode={"environment"} //or user
/>

@@ -38,2 +38,46 @@ );

### Validating qr code result
```tsx
import { useState } from "react";
import { Exception, QrCodeScanner } from "react-simple-qr-code-scanner";
type QrCodeData = {
foo: string;
bar: number;
};
function App() {
return (
<>
<QrCodeScanner
validate={(data) => {
if (!data || data == null || typeof data != "object")
throw new Error("data is required");
if (
!Object.prototype.hasOwnProperty.call(data, "foo") ||
!("foo" in data) ||
data.foo == null ||
typeof data.foo != "string"
)
throw new Error("foo is required");
if (
!Object.prototype.hasOwnProperty.call(data, "bar") ||
!("bar" in data) ||
data.bar ||
typeof data.bar != "number"
)
throw new Error("bar is required");
return { foo: data.foo, bar: data.bar };
}}
onResult={(result) => {
console.log(result); // result will be of type IQrCodeData here (since the validation checks for this)
}}
onError={(errorScan) => {
console.log(errorScan.message); // Get the error messages or any other error message
}}
/>
</>
);
}
```
## License

@@ -40,0 +84,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc