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/api/hooks.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,7 +216,7 @@ The `useMessages` hook allows you to track and manage the chatbot's messages.
216
216
| endStreamMessage |`async function`| Refer [here](/api/params#endstreammessage)| A utility function used to indicate the end of an existing message stream, identical to `params.endMessageStream`. |
217
217
| removeMessage |`async function`| Refer [here](/api/params#removemessage)| A utility function used to remove a message from the chat, identical to `params.removeMessage`. |
218
218
| messages |`Array<Message>`| - |Array containing all messages currently shown in the chatbot. |
219
-
| replaceMessages |`function`|**newMessages (required)** - `Message[]` to replace chat with| Directly replaces the current messages with provided messages. |
219
+
| replaceMessages |`function`|**newMessagesOrUpdater (required)** - Either: (1) `Message[]` to replace chat with, or (2) a callback `(prevMessages: Message[]) => Message[]` returning the new messages. | Directly replaces the current messages with provided messages, or computes them from the previous state.|
220
220
221
221
#### Code Example
222
222
```jsx
@@ -298,8 +298,7 @@ The `usePaths` hook allows you to track and manage the chatbot's paths.
298
298
| getPrevPath |`function`| - | Retrieves the previous path of the user. |
299
299
| goToPath |`function`| Refer [here](/api/params#gotopath)| Sends the user to a specified path, identical to `params.goToPath`. |
300
300
| paths |`Array<string>`| - | Array containing all paths the user has taken in order. |
301
-
| replacePaths |`function`|**newPaths (required)** - `string[]` containing paths to replace with | Directly replaces the current paths with provided paths (hardly a reason to do this, think twice). |
302
-
301
+
| replacePaths |`function`|**newPathsOrUpdater (required)** – Either: (1) `string[]` containing paths to replace with, or (2) a callback `(prevPaths: string[]) => string[]` returning the new paths. | Directly replaces the current paths with provided paths, or computes them from the previous state (hardly a reason to do this, think twice). |
303
302
304
303
#### Code Example
305
304
```jsx
@@ -329,7 +328,7 @@ The `useSettings` hook allows you to track and manage the chatbot's settings.
| settings |`Settings`| - | Represents the current settings of the chatbot. |
332
-
| replaceSettings |`function`|**newSettings (required)**- `Settings` to replace with| Directly replaces the current settings with provided settings. |
331
+
| replaceSettings |`function`|**newSettingsOrUpdater (required)**– Either: (1) `Settings` to replace with, or (2) a callback `(prevSettings: Settings) => Settings` returning the new settings. | Directly replaces the current settings with provided settings, or computes them from the previous state.|
333
332
| updateSettings |`function`|**fields (required)** - `Settings` fields to update | Modifies and merges the provided settings with existing settings. |
334
333
335
334
#### Code Example
@@ -362,7 +361,7 @@ The `useStyles` hook allows you to track and manage the chatbot's styles.
| styles | `Styles` | - | Represents the current styles of the chatbot. |
365
-
| replaceStyles | `function` | **newStyles (required)** - `Styles` to replace with | Directly replaces the current styles with provided styles. |
364
+
| replaceStyles | `function` | **newStylesOrUpdater (required)** – Either: (1) `Styles` to replace with, or (2) a callback `(prevStyles: Styles) => Styles` returning the new styles. | Directly replaces the current styles with provided styles, or computes them from the previous state. |
366
365
| updateStyles | `function` | **fields (required)** - `Styles` fields to update | Modifies and merges the provided styles with existing styles. |
367
366
368
367
#### Code Example
@@ -431,7 +430,7 @@ The `useToasts` hook allows you to track and manage the chatbot's toasts.
431
430
| showToast | `asyncfunction` | Refer [here](/api/params#showtoast) | Shows a toast in chat, identical to `params.showToast`. |
432
431
| dismissToast | `async function` | Refer [here](/api/params#dismisstoast) | Dismisses a toast from chat, identical to `params.dismissToast`. |
433
432
| toasts | `Array<Toast>` | - | Array containing all toasts currently shown in the chatbot. |
434
-
| replaceToasts | `function` | **newToasts (required)** - `Toast[]` to replace with| Directly replaces the current toasts with provided toasts. |
433
+
| replaceToasts | `function` | **newToastsOrUpdater (required)** – Either: (1) `Toast[]` to replace with, or (2) a callback `(prevToasts: Toast[]) => Toast[]` returning the new toasts. | Directly replaces the current toasts with provided toasts, or computes them from the previous state. |
0 commit comments