mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-03-22 02:51:53 +00:00
perf: use websocket context
This commit is contained in:
12
src/hooks/use-websocket-context.ts
Normal file
12
src/hooks/use-websocket-context.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user