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

ParameterType / variantsPurposeDefault
dialog() => ReactElement<DialogProps>Function that creates the dialog.—
dependencies?readonly unknown[]Dependencies of the dialog factory.—

Returns

ValueType / variantsPurpose
openDialog() => stringOpens the dialog and returns its id.

On this page