Get Started
Installation
npm
yarn
pnpm
npm install react-handle-alert
Basic Usage
import React from "react";import { handleAlert, handleConfirm } from "react-handle-alert";const App = () => {const onAlert = () => {handleAlert( "alert!");}const onConfirm = async() => {if (await handleConfirm("Are you sure?")) {// confirm event} else {// cancel event}}return (<div><button onClick={onAlert}>open alert</button><button onClick={onConfirm}>open confirm</button></div>);};export default App;
Using hook
import { handleAlert, handleConfirm } from "react-handle-alert";const useAlert = () => {const onAlert = (text) => handleAlert(text, {// custom options)}const onConfirm = async(text) => await handleConfirm(text), {// custom options})return { onAlert, onConfirm };};