npm.io
0.1.5 • Published 5d ago

askance

Licence
MIT
Version
0.1.5
Deps
1
Size
66 kB
Vulns
0
Weekly
17

askance

Promise-based confirmation dialogs for React Native and Expo apps.

Usage

Mount the host once near the app root:

import {ConfirmDialogHost} from "askance"

export default function App() {
  return <ConfirmDialogHost />
}

Ask for confirmation from handlers:

import {confirmDialog} from "askance"

if (await confirmDialog("Are you sure?")) {
  await model.destroy()
}

Customize one dialog:

await confirmDialog({
  cancelLabel: "Cancel",
  confirmLabel: "Delete",
  danger: true,
  message: "Delete this record?",
  title: "Confirm deletion"
})

Keyboard

  • Enter confirms.
  • Escape cancels.
  • Pressing the backdrop cancels.

Test IDs

The default dialog root is askance-confirm.

  • askance-confirm-confirm
  • askance-confirm-cancel
  • askance-confirm-message
  • askance-confirm-title

Keywords