Skip to content

Commit 8015941

Browse files
committed
3.2.2000 react strict mode; debug image fix
1 parent e36eef8 commit 8015941

File tree

2 files changed

+6
-13
lines changed
  • barcode-scanner-api-samples/scan-single-barcode/react/src
  • foundational-api-samples/others/debug/public

2 files changed

+6
-13
lines changed

barcode-scanner-api-samples/scan-single-barcode/react/src/App.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import { BarcodeScanner, type BarcodeScannerConfig } from "dynamsoft-barcode-rea
44

55
function App() {
66
const barcodeScannerViewRef = useRef(null);
7-
const hasRun = useRef(false); // walkaround react strict mode
87

9-
useEffect(() => {
10-
if(hasRun.current){ return; } // walkaround react strict mode
8+
useEffect(() => {
119

1210
// Configuration object for initializing the BarcodeScanner instance
1311
const config: BarcodeScannerConfig = {
@@ -43,14 +41,10 @@ function App() {
4341
}
4442
})();
4543

46-
hasRun.current = true;
47-
48-
//// We have bug in react strict mode.
49-
//// It will be fixed in next version.
50-
// return ()=>{
51-
// // Dispose of the barcode scanner when the component unmounts
52-
// barcodeScanner?.dispose();
53-
// };
44+
return ()=>{
45+
// Dispose of the barcode scanner when the component unmounts
46+
barcodeScanner?.dispose();
47+
};
5448
}, []);
5549

5650
return (

foundational-api-samples/others/debug/public/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ <h1 style="font-size: 1.5em">Read Barcodes from Camera - Debug</h1>
7070
let ss = await cvRouter.getSimplifiedSettings("ReadBarcodes_SpeedFirst");
7171
ss.timeout = 100000;
7272
ss.minImageCaptureInterval = 100;
73-
ss.capturedResultItemTypes |= Dynamsoft.Core.EnumCapturedResultItemType.CRIT_ORIGINAL_IMAGE;
73+
ss.outputOriginalImage = true;
7474
await cvRouter.updateSettings("ReadBarcodes_SpeedFirst", ss);
7575

7676
// Define a callback for results.
7777
const resultReceiver = new Dynamsoft.CVR.CapturedResultReceiver();
7878
let processingCount = 0;
7979
resultReceiver.onCapturedResultReceived = async (result) => {
8080
const resultItems = result.items;
81-
if (!resultItems.length) return;
8281

8382
if (resultItems.some((item) => item.type === "barcode")) {
8483
Dynamsoft.DCE.Feedback.beep();

0 commit comments

Comments
 (0)