burgos-confirm
v1.3.1
Published
#### A hook, context and component for rendering @mui/material dialog globally with variable title, text content, button name and on confirm callback
Downloads
23
Readme
Confirm dialog
A hook, context and component for rendering @mui/material dialog globally with variable title, text content, button name and on confirm callback
Preparation
wrap your app in and place the component:
<ConfirmDialogProvider>
<App />
<ConfirmDialog />
<ConfirmDialogProvider/>
Usage
Use the useConfirmDialog hook to retrieve the method and call it passing the title, content and onConfirm as an object:
import { useConfirmDialog } from 'burgos-confirm'
export const App = () => {
const { confirm } = useConfirmDialog()
const handleClick = () => {
confirm({
title: 'Confirmation',
content: 'Are you sure you want to delete this object?',
onConfirm: () => console.log(' object deleted')
})
}
}