|
5 | 5 | [](https://github.com/volkov85/react-realtime-hooks/actions/workflows/pages.yml) |
6 | 6 | [](https://github.com/volkov85/react-realtime-hooks/blob/main/LICENSE) |
7 | 7 | [](https://www.typescriptlang.org/) |
8 | | -[](https://www.npmjs.com/package/react) |
| 8 | +[](https://www.npmjs.com/package/react) |
9 | 9 |
|
10 | 10 | Production-ready React hooks for WebSocket and SSE with auto-reconnect, heartbeat, typed connection state, and browser network awareness. |
11 | 11 |
|
@@ -60,7 +60,7 @@ npm install react-realtime-hooks |
60 | 60 |
|
61 | 61 | Peer dependency: |
62 | 62 |
|
63 | | -- `react@^18.3.0 || ^19.0.0` |
| 63 | +- `react@^19.0.0` |
64 | 64 |
|
65 | 65 | ## How It Feels |
66 | 66 |
|
@@ -354,7 +354,7 @@ export function NetworkIndicator() { |
354 | 354 | | `shouldReconnect` | `(event) => boolean` | `true` | Reconnect gate on close | |
355 | 355 | | `onOpen` | `(event, socket) => void` | `undefined` | Open callback | |
356 | 356 | | `onMessage` | `(message, event) => void` | `undefined` | Message callback | |
357 | | -| `onError` | `(event) => void` | `undefined` | Error callback | |
| 357 | +| `onError` | `(event) => void` | `undefined` | Called for transport, heartbeat, and parse errors | |
358 | 358 | | `onClose` | `(event) => void` | `undefined` | Close callback | |
359 | 359 |
|
360 | 360 | ### Result |
@@ -397,7 +397,7 @@ When you configure `useWebSocket` heartbeat, you can also set `timeoutAction` an |
397 | 397 | | `shouldReconnect` | `(event) => boolean` | `true` | Reconnect gate on error | |
398 | 398 | | `onOpen` | `(event, source) => void` | `undefined` | Open callback | |
399 | 399 | | `onMessage` | `(message, event) => void` | `undefined` | Default `message` callback | |
400 | | -| `onError` | `(event) => void` | `undefined` | Error callback | |
| 400 | +| `onError` | `(event) => void` | `undefined` | Called for transport and parse errors | |
401 | 401 | | `onEvent` | `(eventName, message, event) => void` | `undefined` | Named event callback | |
402 | 402 |
|
403 | 403 | ### Result |
@@ -512,7 +512,8 @@ When you configure `useWebSocket` heartbeat, you can also set `timeoutAction` an |
512 | 512 |
|
513 | 513 | - `useEventSource` is receive-only by design. SSE is not a bidirectional transport. |
514 | 514 | - `useWebSocket` heartbeat support is client-side. You still define your own server ping/pong protocol. |
515 | | -- If `parseMessage` throws, the hook closes the current transport, moves into `error`, stores `lastError`, and stops auto-reconnect until manual `open()` or `reconnect()`. |
| 515 | +- If `parseMessage` throws, the hook calls `onError`, closes the current transport, moves into `error`, stores `lastError`, and stops auto-reconnect until manual `open()` or `reconnect()`. |
| 516 | +- Stopping heartbeat clears timeout state and the previous beat/ack timestamps so a new session starts with fresh metrics. |
516 | 517 | - `connect: false` keeps the hook in `idle` until `open()` is called. |
517 | 518 | - Manual `close()` is sticky. The hook stays closed until `open()` or `reconnect()` is called. |
518 | 519 | - No transport polyfills are bundled. Provide your own runtime support where needed. |
|
0 commit comments