useModal
The useModal
hook provides a simple way to manage the state of a modal, allowing you to easily open and close the modal with provided functions. This hook returns the current state of the modal (whether it is open or closed) along with functions to open and close the modal.
Usage
First, you need to import the useModal
hook from the kitchn
package.
import { useModal } from "kitchn";
Example
Here is an example of how to use the useModal
hook in a component:
Parameters
The useModal
hook does not accept any parameters.
Return Value
The useModal
hook returns a tuple with the following elements:
Name | Type | Description |
---|---|---|
isOpen | boolean | A boolean value indicating whether the modal is currently open. |
open | () => void | A function to open the modal by setting its state to true . |
close | () => void | A function to close the modal by setting its state to false . |