useDialog
Reads dialogs from DialogProvider and closes the active or a specified dialog.
Reads dialogs from DialogProvider and closes the active or a specified dialog.
Call this inside DialogProvider or PBCProvider.
Usage
'use client';
import { useDialog } from '@prosazhin/pbcomponents';
function CloseButton() {
const { activeDialog, closeDialog } = useDialog();
return <button onClick={() => closeDialog(activeDialog?.id)}>Close</button>;
}Hook API
Returns
| Value | Type / variants | Purpose |
|---|---|---|
dialogs | DialogRecord[] | Registered dialogs. |
activeDialog | DialogRecord | null | Active dialog or null. |
closeDialog | (id?: string) => void | Closes a dialog by id or the active dialog when no id is given. |