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

ValueType / variantsPurpose
dialogsDialogRecord[]Registered dialogs.
activeDialogDialogRecord | nullActive dialog or null.
closeDialog(id?: string) => voidCloses a dialog by id or the active dialog when no id is given.

On this page