QR Code Reader / Scanner in React (Html5-QRCode.js)

preview_player
Показать описание
‍🎓 NEW: Earn a professional certificate in web development from Meta Inc. (course links in card below) 👇

This tutorial shows you how to implement a QR code reader / scanner in React using the Html5-QRCode library.
#react #qrcode #tutorial #reacttutorial#reactjs #reactjstutorial

⚡Web development professional certificates from Meta Inc.⚡
Рекомендации по теме
Комментарии
Автор

Hi, I tried it with Nextjs 15 and it worked. Awesome!

ismytv
Автор

Very useful. We need to make an inventory using a barcode. Thank you for your free tutorial.

mr.RAND
Автор

but for my laptop it is not opening the camera why?? i have did what you told but it is not working

web-jl
Автор

import React, { useEffect, useState } from 'react';
import { Html5QrcodeScanner } from 'html5-qrcode';
import './App.css';

function App() {
const [scanResult, setScanResult] = useState(null);
const [manualSerialNumber, setManualSerialNumber] = useState('');

useEffect(() => {
const scanner = new Html5QrcodeScanner('reader', {
qrbox: {
width: 250,
height: 250,
},
fps: 5,
});

let isScanning = true;

scanner.render(success, error);

function success(result) {
if (isScanning) {
scanner.clear();
setScanResult(result);
isScanning = false; // Set isScanning to false to stop further scanning
}
}

function error(err) {
console.warn(err);
}
}, []);

function {

}

return (
<div className="App">
<h1>QR Scanning Code</h1>
{scanResult ? (
<div>
<p>Success: <a
<p>Serial Number: {scanResult.slice(-16)}</p>
</div>
) : (
<div>
<div id="reader"></div>
<p className="center-text">Or enter the serial number manually:</p>
<div className="center-input">
<input
type="text"
value={manualSerialNumber}

/>
{manualSerialNumber && (
<p>Serial Number:
)}
</div>
</div>
)}
</div>
);
}

export default App;

Hi...this code doesn't scan using a live camera but only when i upload the might be the problem?

EvenceMohauLanga-md
Автор

hello. Thanks for the good solution.
Is it possible to communicate with the server by binding data to QR code?
Is it possible to scan the QR code and display a modal window rather than a results page?

I've been thinking about solving this problem for several days.

parkj
Автор

Very good video tutorial, I have a question:
is it possible to modify the interface and labels of the qr reader?

juryhc
Автор

This is a cool tutorial but for some reason I keep gettign this error "Uncaught HTML Element with id=reader not found".

cosmasdaniella
Автор

Good tutorial.I am loading this in webview for android app.But the cam is not opened for QR code.It triggers error.Also the qr code image path is not loaded.
Any idea?

ila
Автор

very good tutorial helped me alot, thankyou

teclyt_solutions
Автор

Is there any way to upload image as an identification card with a qr-code in it and scan it ? I tried it right now it doesn't recognize the qr-code in it

MiyaIzumi-qn
Автор

thanks for the code
but i want when i click on the turnon button then only camera start not before

yashpataliya
Автор

How to fix :Uncaught TypeError: Cannot read properties of null (reading 'videoWidth')

TanaTorn-nj
Автор

Hi, is it possible to use an external camera? Like cam scanner, web cam or something else

nanaana
Автор

Why do you sound like you are being kidnapped lol

lifeofstephen-yt
Автор

Hello! am i the only one who gets 23 warnings like this one:
WARNING in
Module Warning (from
Failed to parse source map from file: Error: ENOENT: no such file or directory, open

????

Thanks for the video! ill keep trying to make it work

Kratosgod
Автор

HTML Element with id=reader not found
i'm getting this error

sriharibolisetti
Автор

console.log(scanResult) in useEffect no value

evobbvz
visit shbcf.ru