mirror of
https://github.com/woodchen-ink/nezha-dash-v1.git
synced 2025-07-18 17:41:56 +08:00
13 lines
346 B
TypeScript
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;
|
|
};
|