Skip to content

Commit

Permalink
feat(hooks): expose onOpenChange in useDisclosure
Browse files Browse the repository at this point in the history
  • Loading branch information
zlatanpham committed Nov 29, 2023
1 parent 339f37b commit c4277bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/early-insects-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@dwarvesf/react-toolkit-docs': minor
'@dwarvesf/react-hooks': minor
---

Expose onOpenChange
7 changes: 4 additions & 3 deletions docs/pages/hooks/use-disclosure.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ The `useDisclosure` hook returns an object with the following fields:
| Name | Type | Default | Description |
| ---------- | ---------- | ------- | ------------------------------------------------------------------- |
| `isOpen` | `boolean` | `false` | If `true`, it sets the controlled component to its visible state. |
| `onClose` | `function` | `_` | Callback function to set a falsy value for the `isOpen` parameter. |
| `onOpen` | `function` | `_` | Callback function to set a truthy value for the `isOpen` parameter. |
| `onToggle` | `function` | `_` | Callback function to toggle the value of the `isOpen` parameter. |
| `onClose` | `() => void` | `_` | Callback function to set a falsy value for the `isOpen` parameter. |
| `onOpen` | `() => void` | `_` | Callback function to set a truthy value for the `isOpen` parameter. |
| `onToggle` | `() => void` | `_` | Callback function to toggle the value of the `isOpen` parameter. |
| `onOpenChange` | `(isOpen: boolean) => void` | `_` | Callback function to set the value for the `isOpen` parameter. |

## Usage

Expand Down
1 change: 1 addition & 0 deletions packages/hooks/src/useDisclosure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function useDisclosure(props: UseDisclosureProps = {}) {
return {
isOpen: !!isOpen,
prevIsOpen: !!prevIsOpen,
onOpenChange: setIsOpen,
onOpen,
onClose,
onToggle,
Expand Down

0 comments on commit c4277bc

Please sign in to comment.