useDisclosure ​
Hook that allows you to open and close a modal
utilities
test coverage
Last changed: last month
Installation ​
Library
CLI
Manual
typescript
import { useDisclosure } from '@siberiacancode/reactuse';
Usage ​
typescript
const { opened, open, close, toggle } = useDisclosure();
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
initialValue? | boolean | false | The initial value of the component |
options.onOpen? | () => void | - | The callback function to be invoked on open |
options.onClose? | () => void | - | The callback function to be invoked on close |
Returns
UseDisclosureReturn
Type declaration ​
typescript
export interface UseDisclosureOptions {
/** The callback function to be invoked on close */
onClose?: () => void;
/** The callback function to be invoked on open */
onOpen?: () => void;
}
export interface UseDisclosureReturn {
/** The opened value */
opened: boolean;
/** Function to close the modal */
close: () => void;
/** Function to open the modal */
open: () => void;
/** Function to toggle the modal */
toggle: () => void;
}
Source ​
Source • DemoContributors ​
D
H