Skip to content

Commit

Permalink
[INJIVER-127] Update QR code scanning and upload libraries (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth716 authored Aug 27, 2024
1 parent eb27f0b commit f2d2f77
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions inji-verify/src/components/Home/VerificationSection/QrScanner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useCallback, useEffect, useRef, useState } from "react";
import CameraAccessDenied from "./CameraAccessDenied";
import { ScanSessionExpiryTime } from "../../../utils/config";
import { useAppDispatch } from "../../../redux/hooks";
Expand All @@ -18,15 +18,18 @@ function QrScanner() {

const scannerRef = useRef<HTMLDivElement>(null);

const onSuccess = (decodedText: any) => {
dispatch(
verificationInit({
qrReadResult: { qrData: decodedText, status: "SUCCESS" },
flow: "SCAN",
})
);
clearTimeout(timer);
};
const onSuccess = useCallback(
(decodedText: any) => {
dispatch(
verificationInit({
qrReadResult: { qrData: decodedText, status: "SUCCESS" },
flow: "SCAN",
})
);
clearTimeout(timer);
},
[dispatch]
);

useEffect(() => {
timer = setTimeout(() => {
Expand All @@ -46,7 +49,7 @@ function QrScanner() {
console.log("Clearing timeout");
clearTimeout(timer);
};
}, [dispatch]);
}, [dispatch, onSuccess]);

useEffect(() => {
// Disable inbuilt border around the video
Expand Down

0 comments on commit f2d2f77

Please sign in to comment.