You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/realtime/overview.mdx
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,10 @@ for await (const run of runs.subscribeToBatch("batch-id")) {
69
69
}
70
70
```
71
71
72
+
### React hooks
73
+
74
+
We also provide a set of React hooks that make it easy to use the Realtime API in your React components. See the [React hooks doc](/frontend/react-hooks) for more information.
75
+
72
76
## Run changes
73
77
74
78
You will receive updates whenever a run changes for the following reasons:
if (error) return <div>Error: {error.message}</div>;
19
+
20
+
return (
21
+
<div>
22
+
{runs.map((run) => (
23
+
<divkey={run.id}>Run: {run.id}</div>
24
+
))}
25
+
</div>
26
+
);
27
+
}
28
+
```
29
+
30
+
</RequestExample>
31
+
32
+
This react hook subscribes to all changes to runs with a specific tag. See the [React hooks doc](/frontend/react-hooks) for more information on how to use this hook.
33
+
34
+
### Response
35
+
36
+
The react hook returns an object with the following properties:
37
+
38
+
<ParamFieldpath="runs"type="object[]"required>
39
+
An array of run objects. See the [Run object doc](/realtime/overview#run-object) for more
40
+
information.
41
+
</ParamField>
42
+
43
+
<ParamFieldpath="error"type="Error">
44
+
An error object if an error occurred while subscribing.
0 commit comments