useDisclosure
useDisclosure
is a custom hook used to help handle common open, close, or
toggle scenarios. It can be used to control feedback component such as Modal,
AlertDialog, Drawer.
Import#
import { useDisclosure } from '@dwarvesf/react-hooks'
Return value#
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 | () => 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#
Parameters#
The useDisclosure
hook accepts an optional object with the following
properties:
Name | Type | Default | Description |
---|---|---|---|
defaultIsOpen | boolean | false | The default value. |
onClose | () => void | _ | The callback when the isOpen is set to false . |
onOpen | () => void | _ | The callback when the isOpen is set to true . |