1.0.8 • Published 5 years ago
rc-confirm-alert v1.0.8
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 }) { ... }