Sponsor

useDisclosure

useDisclosure is a custom hook to help handle common open, close, or toggle scenarios. It can be used to control feedback component such as Modal, AlertDialog, Drawer, etc.

Import#

Return value#

The useDisclosure hook returns an object with the following fields:

NameTypeDefaultDescription
isOpenbooleanfalseIf true, it sets the component to it's visible state.
onClosefunctionFunction that sets isOpen to false.
onOpenfunctionFunction that sets isOpen to true.
onTogglefunctionFunction that toggles isOpen between true and false

Usage#

Editable Example

Proudly made in 🇳🇬

Released under the MIT License.

Copyright © 2020 Segun Adebayo