useShowDialog
Registers a dialog and returns a function to open it.
Registers a dialog and returns a function to open it.
Call this inside DialogProvider or PBCProvider.
Usage
'use client';
import { Dialog, useShowDialog } from '@prosazhin/pbcomponents';
function Example() {
const open = useShowDialog(() => (
<Dialog id='example'>
<Dialog.Content>
<Dialog.Body>Content</Dialog.Body>
</Dialog.Content>
</Dialog>
));
return <button onClick={open}>Open</button>;
}Hook API
Parameters
| Parameter | Type / variants | Purpose | Default |
|---|---|---|---|
dialog | () => ReactElement<DialogProps> | Function that creates the dialog. | — |
dependencies? | readonly unknown[] | Dependencies of the dialog factory. | — |
Returns
| Value | Type / variants | Purpose |
|---|---|---|
openDialog | () => string | Opens the dialog and returns its id. |