Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hieptn94/react-headless-confirm

Headless, Promise-based confirm component for React
https://github.com/hieptn94/react-headless-confirm

npm react reactcomponent typescript yarn

Last synced: about 1 month ago
JSON representation

Headless, Promise-based confirm component for React

Awesome Lists containing this project

README

        

# react-confirmation

Headless, Promise-based confirm component for React.

## Example

Build the library:
> yarn install && yarn build

Run example:
> cd example && yarn install && yarn start

## Usage

```js
import { ConfirmProvider, useConfirm } from 'react-headless-confirm';

// ConfirmProvider must be placed on top of your components.
function App() {
return (



);
}

function Example() {
const { confirm } = useConfirm();
const handleConfirm = async () => {
const isConfirmed = await confirm({
title: 'Your Title',
content: 'Your Content',
confirmText: 'Your Confirm Text',
cancelText: 'Your Cancel Text',
});

// Do something when the user confirm or cancel.
console.log(isConfirmed);
}
return (
Open Confirm
);
}
```

## License

[MIT](LICENSE)