logo

react-handle-alert

Introduction

default alert

default confirm

custom alert

custom confirm

react-handle-alert is designed to be used as pure functions without the need for integrating any components into your React component tree. This makes it incredibly easy to trigger alerts and confirmations directly from your functional logic or event handlers.

Features

  • Custom Alerts: Displays custom alerts that provide information to users.

  • Custom Confirms: Enables the implementation of confirmation dialogs that require user decisions.

  • Fully Customizable: Allows for the customization of modal backgrounds, styles, button texts, and button styles.

Simple Usage

import { handleAlert, handleConfirm } from "react-handle-alert";
# alert
handleAlert("alert message")
# confirm
handleConfirm("confirm message").then(action => {
console.log(action ? "confirm", "cancel");
})
# OR
const action = await handleConfirm("confirm message");
console.log(action ? "confirm", "cancel");