Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/hieptn94/react-headless-confirm
- Owner: hieptn94
- License: mit
- Created: 2020-12-14T08:25:03.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2020-12-20T15:31:05.000Z (almost 4 years ago)
- Last Synced: 2024-03-24T11:20:43.216Z (8 months ago)
- Topics: npm, react, reactcomponent, typescript, yarn
- Language: TypeScript
- Homepage:
- Size: 356 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-confirmation
Headless, Promise-based confirm component for React.
## Example
Build the library:
> yarn install && yarn buildRun 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)