useSocketState
Import
import { useSocketState } from "@hyper-fetch/react"
Source
Package
Parameters
useSocketState<DataType, Socket>(socket: Socket, __namedParameters: UseSocketStateProps)
Parameters
| Name | Type | Description |
|---|---|---|
| socket | | |
| __namedParameters | |
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 }]