useWebSocketState
Read state built by createWebSocketState. Re-renders only when the selected value changes.
Usage
Parameters
Returns
The selected value.
Behavior
- Renders. It re-renders when the selected value changes, not on every message or on every change to other parts of the state. With a store created with
batch: 'frame', that's at most once per animation frame. - Inline selectors. Inline selectors are fine. If one returns a new object or array, pass an
isEqualsuch as a shallow comparison. - Connection. It holds the store's client connection while mounted, like the other hooks.
- Server rendering. On the server and during hydration, it selects from
initialState.