You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
68
+
if (scanner.isContextDestroyed()) return;
69
+
awaitscanner.setUIElement(elRef.current!);
70
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
if (ex.message.indexOf("network connection error")) {
83
+
let customMsg =
84
+
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
85
+
console.log(customMsg);
86
+
alert(customMsg);
87
+
}
88
+
throwex;
89
+
}
90
+
})();
65
91
return () => {
66
92
(async () => {
67
-
if (pScanner) {
68
-
(awaitpScanner).destroyContext();
93
+
if (pScanner.current) {
94
+
(awaitpScanner.current).destroyContext();
69
95
console.log("BarcodeScanner Component Unmount");
70
96
}
71
97
})();
72
98
};
73
99
}, []);
74
100
75
-
useEffect(() => {
76
-
if (elRef.current) {
77
-
(async () => {
78
-
try {
79
-
const scanner = (awaitpScanner)!;
80
-
// Should judge if scanner is destroyed after 'await' in React 18 'StrictMode'.
81
-
if (scanner.isContextDestroyed()) return;
82
-
awaitscanner.setUIElement(elRef.current!);
83
-
// Should judge if scanner is destroyed after 'await' in React 18 'StrictMode'.
if (ex.message.indexOf("network connection error")) {
96
-
let customMsg =
97
-
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
14
+
if(scanner.isContextDestroyed())return;
15
+
awaitscanner.setUIElement(elRef.current!);
16
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
31
+
console.log(customMsg);
32
+
alert(customMsg);
33
+
}
34
+
throwex;
35
+
}
36
+
})();
11
37
return()=>{
12
38
(async()=>{
13
-
if(pScanner){
14
-
(awaitpScanner).destroyContext();
39
+
if(pScanner.current){
40
+
(awaitpScanner.current).destroyContext();
15
41
console.log("BarcodeScanner Component Unmount");
16
42
}
17
43
})();
18
44
};
19
45
},[]);
20
46
21
-
useEffect(()=>{
22
-
if(elRef.current){
23
-
(async()=>{
24
-
try{
25
-
constscanner=(awaitpScanner)!;
26
-
// Should judge if scanner is destroyed after 'await' in React 18 'StrictMode'.
27
-
if(scanner.isContextDestroyed())return;
28
-
awaitscanner.setUIElement(elRef.current!);
29
-
// Should judge if scanner is destroyed after 'await' in React 18 'StrictMode'.
"Failed to connect to Dynamsoft License Server: network connection error. Check your Internet connection or contact Dynamsoft Support (support@dynamsoft.com) to acquire an offline license.";
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
65
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
66
66
if(scanner.isContextDestroyed()) return;
67
67
awaitscanner.setUIElement(this.elRef.current!);
68
-
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
68
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
11
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
12
12
if(scanner.isContextDestroyed())return;
13
13
awaitscanner.setUIElement(this.elRef.current!);
14
-
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
14
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
61
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
62
62
if(scanner.isContextDestroyed()) return;
63
63
awaitscanner.setUIElement(this.elRef.current!);
64
-
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
64
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
10
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
11
11
if(scanner.isContextDestroyed())return;
12
12
awaitscanner.setUIElement(this.elRef.current!);
13
-
// Should judge if scanner is destroyed after 'await'in React 18 'StrictMode'.
13
+
// Should judge if scanner is destroyed after 'await', as in development React runs setup and cleanup one extra time before the actual setup in Strict Mode.
0 commit comments