aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/hooks/useWebSocket.ts
blob: 8fe688f2d1a5f793a2e8d1f4961852e1e8df3da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import useWebSocketOriginal, { ReadyState } from "react-use-websocket";

export { ReadyState };

// Typed version of useWebSocket() hook.
export default function useWebSocket<ReceiveMessage, SendMessage>(
	url: string,
): {
	sendJsonMessage: (message: SendMessage) => void;
	lastJsonMessage: ReceiveMessage;
	readyState: ReadyState;
} {
	return useWebSocketOriginal(url);
}