Skip to content

Commit efa21b5

Browse files
authored
fix: add optional chaining for function check in useConnectionState (#1297)
1 parent 17a93fe commit efa21b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/hooks/useConnectionState.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const useConnectionState = (): ConnectionState => {
1515
useEffect(() => {
1616
const handlerId = uuidv4();
1717

18-
sdk?.addConnectionHandler(handlerId, new ConnectionHandler({
18+
sdk?.addConnectionHandler?.(handlerId, new ConnectionHandler({
1919
onConnected: () => setConnectionState(ConnectionState.OPEN),
2020
onDisconnected: () => setConnectionState(ConnectionState.CLOSED),
2121
onReconnectStarted: () => setConnectionState(ConnectionState.CONNECTING),
@@ -24,7 +24,7 @@ export const useConnectionState = (): ConnectionState => {
2424
}));
2525

2626
return () => {
27-
sdk?.removeConnectionHandler(handlerId);
27+
sdk?.removeConnectionHandler?.(handlerId);
2828
};
2929
}, [sdk]);
3030

0 commit comments

Comments
 (0)