socket.io-react-hooks-advanced
Version:
A modular and extensible React + Socket.IO hook library designed for real-world applications. Supports namespaced sockets, reconnection strategies, offline queues, latency monitoring, middleware, encryption, and more.
14 lines (10 loc) • 336 B
text/typescript
import {createContext, useContext} from "react";
import {SocketContextType} from "./SocketContext";
export const createSocketContext = () => {
const Context = createContext<SocketContextType>({
socket: null,
connected: false,
});
const useCtx = () => useContext(Context);
return {Context, useCtx};
};