Skip to content

Commit 63b1670

Browse files
authored
Merge pull request #227 from Dynamsoft/_dev
update useeffect return function
2 parents 0f0b802 + a3a85a0 commit 63b1670

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

hello-world/react-hooks/src/components/ImageCapture/ImageCapture.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ function ImageCapture() {
5353
isDestroyed.current = false;
5454

5555
// componentWillUnmount. dispose cvRouter when it's no longer needed
56-
return async () => {
56+
return () => {
5757
isDestroyed.current = true;
5858
if (pCvRouter.current) {
59-
try {
60-
(await pCvRouter.current).dispose();
61-
} catch (_) {}
59+
pCvRouter.current.then((cvRouter) => {
60+
cvRouter.dispose();
61+
}).catch((_) => { })
6262
}
6363
};
6464
}, []);

hello-world/react-hooks/src/components/VideoCapture/VideoCapture.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ function VideoCapture() {
9191
})();
9292

9393
// componentWillUnmount. dispose cvRouter when it's no longer needed
94-
return async () => {
94+
return () => {
9595
isDestroyed = true;
96-
try {
97-
// Wait for the pInit to complete before disposing resources.
98-
await pInit;
96+
// Wait for the pInit to complete before disposing resources.
97+
pInit.then(() => {
9998
cvRouter?.dispose();
10099
cameraEnhancer?.dispose();
101-
} catch (_) { }
100+
}).catch((_) => { })
102101
};
103102
}, []);
104103

0 commit comments

Comments
 (0)