Skip to main content
Version: 2.x.x

useSocketState


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

Description

Defined in helpers/use-socket-state/use-socket-state.hooks.ts:7

Preview

useSocketState<DataType>(socket, __namedParameters)

Parameters

NameDetails

socket

Required

Socket<any>

__namedParameters

Required

UseSocketStateProps

Returns

readonly [UseSocketStateType<DataType>, {
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setData: (data: DataType) => void;
setTimestamp: (timestamp: number) => void;
}, {
onClose: (callback: VoidFunction) => void;
onConnecting: (callback: VoidFunction) => void;
onError: (callback: (event: ErrorType) => void) => void;
onOpen: (callback: VoidFunction) => void;
onReconnecting: (callback: (attempts: number) => void) => void;
onReconnectingStop: (callback: (attempts: number) => void) => void;
}, {
setRenderKey: (renderKey: keyof UseSocketStateType<DataType>) => void;
}]