Skip to main content
Version: v7.0.0

useSocketState


Import
import { useSocketState } from "@hyper-fetch/react"

Parameters

useSocketState<DataType, Socket>(socket: Socket, __namedParameters: UseSocketStateProps)
Parameters
NameTypeDescription
socket
Socket
__namedParameters
UseSocketStateProps

Returns

readonly [UseSocketStateType<Socket, DataType>, { setConnected: (connected: boolean) => void; setConnecting: (connecting: boolean) => void; setData: (data: null | DataType) => void; setExtra: (extra: null | ExtractSocketExtraType<Socket>) => void; setTimestamp: (timestamp: null | number) => void }, { onConnected: (callback: VoidFunction) => void; onConnecting: (callback: VoidFunction) => void; onDisconnected: (callback: VoidFunction) => void; onError: <ErrorType>(callback: (event: ErrorType) => void) => void; onReconnecting: (callback: (data: { attempts: number }) => void) => void; onReconnectingFailed: (callback: (data: { attempts: number }) => void) => void }, { setRenderKey: (renderKey: keyof UseSocketStateType<Socket, DataType>) => void }]
React
On this page