nezha-dash-v1/src/hooks/use-websocket-context.ts
2024-11-24 11:32:42 +08:00

13 lines
346 B
TypeScript

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;
};