Skip to content

Commit b919a31

Browse files
committed
Cleanup destroy callback
1 parent a09add5 commit b919a31

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

js/Ice/react-greeter/src/App.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,14 @@ function App(): JSX.Element {
4343
}
4444

4545
return () => {
46-
const cleanup = async () => {
47-
try {
48-
if (communicatorRef.current) {
49-
await communicatorRef.current.destroy();
50-
}
51-
} catch (err) {
52-
console.warn("Failed to destroy communicator:", err);
53-
}
54-
};
55-
// Kick off the async cleanup, but don't return the promise
56-
cleanup();
46+
const communicator = communicatorRef.current;
47+
communicatorRef.current = null;
48+
// Clean up the communicator when the component unmounts
49+
if (communicator) {
50+
communicator.destroy().catch((err) => {
51+
console.error("Error destroying Ice communicator:", err);
52+
});
53+
}
5754
};
5855
}, []);
5956

0 commit comments

Comments
 (0)