perf: use websocket context

This commit is contained in:
hamster1963
2024-11-24 11:32:42 +08:00
parent 56d6305096
commit 5364d5cdb5
7 changed files with 81 additions and 34 deletions

View File

@@ -0,0 +1,12 @@
import { useContext } from "react";
import { WebSocketContext } from "../context/websocket-context";
export const useWebSocketContext = () => {
const context = useContext(WebSocketContext);
if (context === undefined) {
throw new Error(
"useWebSocketContext must be used within a WebSocketProvider",
);
}
return context;
};