Skip to content

Commit e462457

Browse files
committed
chore: Minor updates
1 parent 5f57f29 commit e462457

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

docs/api/hooks.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,13 @@ Below is a list of available hooks along with a brief description for each of th
9090
| useFlow | Allows retrieving and restarting chatbot flow and tracks if flow has started. |
9191
| useMessages | Handles sending, clearing, and retrieving messages in the chatbot. |
9292
| useNotifications | Manages chatbot notifications, such as toggling notifications on or off. |
93-
| usePaths | Manages chatbot conversation paths, such as navigation |
93+
| useOnRcbEvent | Registers a chatbot event with corresponding handler. |
94+
| usePaths | Manages chatbot conversation paths, such as navigation. |
9495
| useSettings | Accesses and modifies chatbot settings. |
9596
| useStyles | Accesses and modifies chatbot styles. |
9697
| useTextArea | Manages the text input area of the chatbot, including setting and clearing values. |
9798
| useToasts | Manages toasts shown within the chatbot, such as showing or missing them. |
98-
| useVoice | Manages voice functionality, such as toggling voice on or off |
99+
| useVoice | Manages voice functionality, such as toggling voice on or off. |
99100

100101
## Hook Details
101102

@@ -323,6 +324,30 @@ const MyNestedComponent = () => {
323324
};
324325
```
325326

327+
### useOnRcbEvent
328+
329+
#### Description
330+
The `useOnRcbEvent` hook allows you to register a chatbot event with its corresponding handler. It accepts 2 parameters, the first being a `RcbEvent` (provided as an `enum` export by the library) and the second being the corresponding event handler. Note that the hook does not return any value since it simply registers an event. This is **commonly used in plugins** which rely on listening on [**events**](/docs/api/events) and taking actions via [**hooks**](/docs/api/hooks).
331+
332+
#### Code Example
333+
```jsx
334+
import { useEffect } from "react";
335+
import { useOnRcbEvent, RcbEvent, RcbChangePathEvent } from "react-chatbotify";
336+
337+
const MyNestedComponent = () => {
338+
const handler = (event: RcbChangePathEvent) => {
339+
// handle change path logic
340+
}
341+
342+
// listens on the change path event
343+
useOnRcbEvent(RcbEvent.CHANGE_PATH, handler);
344+
345+
return (
346+
<ExampleComponent/>
347+
)
348+
};
349+
```
350+
326351
### usePaths
327352

328353
#### Description

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"openai": "^4.47.1",
3131
"prism-react-renderer": "^2.3.1",
3232
"react": "^18.2.0",
33-
"react-chatbotify": "^2.0.0-beta.36",
33+
"react-chatbotify": "^2.0.0-beta.37",
3434
"react-dom": "^18.2.0",
3535
"react-github-btn": "^1.4.0"
3636
},

0 commit comments

Comments
 (0)