{"id":8098,"date":"2023-06-14T05:07:32","date_gmt":"2023-06-14T05:07:32","guid":{"rendered":"https:\/\/www.bacancytechnology.com\/qanda\/?p=8098"},"modified":"2023-07-27T08:51:25","modified_gmt":"2023-07-27T08:51:25","slug":"react-native-barcode-scanning-with-vision-camera","status":"publish","type":"post","link":"https:\/\/www.bacancytechnology.com\/qanda\/react-native\/react-native-barcode-scanning-with-vision-camera","title":{"rendered":"React Native Scan Barcode with Vision Camera"},"content":{"rendered":"<p>For scanning a QR code\/ Barcode using vision camera:<\/p>\n<p>You need to install the below packages:<\/p>\n<ul>\n<li>yarn add react-native-vision-camera<\/li>\n<li>Lyarn add vision-camera-code-scanner<\/li>\n<\/ul>\n<p>After installing the package, you can proceed further by creating a new component<br \/>\nAnd by adding the vision camera configurations in it. Basically we will be using some hooks which are predefined in react-native-vision-camera.<\/p>\n<p>The below example shows how to use it<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import React, { useState } from 'react';\r\nimport { Camera, useScanBarcodes } from 'react-native-vision-camera';\r\nimport { BarcodeFormat } from 'vision-camera-code-scanner';\r\n\r\nconst App = () =&gt; {\r\nconst [barcodes, setBarcodes] = useState([]);\r\n\r\nconst scanBarcodes = useScanBarcodes({\r\nformat: [BarcodeFormat.QR_CODE],\r\n});\r\n\r\nscanBarcodes.subscribe((barcodes) =&gt; {\r\nsetBarcodes(barcodes);\r\n});\r\n\r\nreturn (\r\n&lt;Camera\r\nstyle={{ width: 200, height: 200 }}\r\nonFrameCaptured={(frame) =&gt; {\r\nscanBarcodes(frame);\r\n}}\r\n\/&gt;\r\n);\r\n};\r\n<\/pre>\n<p>export default App;<\/p>\n<p>The above code will help you in configuring a simple and ready to use component which will allow you to scan qr codes. You will get the result if you will scan a qr code and you can configure it accordingly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For scanning a QR code\/ Barcode using vision camera: You need to install the below packages: yarn add react-native-vision-camera Lyarn add vision-camera-code-scanner After installing the package, you can proceed further by creating a new component And by adding the vision camera configurations in it. Basically we will be using some hooks which are predefined in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8351,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-8098","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-react-native"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8098"}],"collection":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/comments?post=8098"}],"version-history":[{"count":3,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8098\/revisions"}],"predecessor-version":[{"id":8352,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/posts\/8098\/revisions\/8352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media\/8351"}],"wp:attachment":[{"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/media?parent=8098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/categories?post=8098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bacancytechnology.com\/qanda\/wp-json\/wp\/v2\/tags?post=8098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}