rc-confirm-alert

alert window

Usage no npm install needed!

<script type="module">
  import rcConfirmAlert from 'https://cdn.skypack.dev/rc-confirm-alert';
</script>

README

rc-confirm-alert

Yet another confirm alert for React

Installation

npm install rc-confirm-alert

Usage

Use it as a function

import { reactAlert } from 'rc-confirm-alert';

reactAlert({
  width: '500px',
  title: 'Are you sure?',
  onCancel: () => doSomethingOnCancel(),
  onConfirm: () => doSomethingOnConfirm(),
});

Also supports hooks

import { useReactAlert } from 'rc-confirm-alert';

function UI() {
  const dialog = useReactAlert();

  return (
    <React.Fragment>
      <button onClick={() => dialog.open()}>Open Modal</button>
    </React.Fragment>
  );
}

Custom UI

import { reactAlert } from 'rc-confirm-alert';

reactAlert({
  render: (props) => <CustomUI {...props} />,
  onCancel: () => { ... },
  onConfirm: () => { ... },
});
function CustomUI({ cancel, confirm }) { ... }