1.0.4 • Published 4 years ago

mui-confirm-modal v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

mui-confirm-modal

A simple util that easily allows us to display confirmation modals for certain actions. Based on react-confirm and material-ui

NPM JavaScript Style Guide

Install

npm install --save mui-confirm-modal

Demo

https://codesandbox.io/s/ecstatic-bush-enxxi

Confirm

This utility allows the dev to easily implement confirmation modals for any action. This works well with nesting modals as well.

title (String) Optional

The title of the modal. The title is 'Confirmation' by default.

message (string) Required

The message displayed in the modal

Example

import React from 'react'
import Button from '@material-ui/core/Button'
import { confirm } from './confirm'

export default function ConfirmModalTemplateExample() {
  const handleOnClick = async () => {
    if (
      await confirm({
        message: 'Do you really want to be batman?'
      })
    ) {
      console.log('yes')
    } else {
      console.log('no')
    }
  }

  return (
    <div>
      <Button variant='outlined' color='primary' onClick={handleOnClick}>
        Open alert dialog
      </Button>
    </div>
  )
}

License

MIT © Naveed-Naqi

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago