1.0.1 • Published 3 years ago

@hookplus/use-confirm v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@hookplus/use-confirm

React Hook to ask the user for a confirmation before executing a function.

Installation

yarn

yarn add @hookplus/use-confirm

npm

npm i @hookplus/use-confirm

Usage

import React from "react";
import useConfirm from "@hookplus/use-confirm";

function App() {
  const deleteWorld = () => console.log("Deleting world...");
  const confirmDelete = useConfirm("Are you sure?", deleteWorld);
  return <button onClick={confirmDelete}>Delete the world</button>;
}

Arguments

ArgumentTypeDescriptionRequired
messagestringMessage to show the user on the confirmation propmtyes
onConfirmfunctionFunction to be executed when the user confirmsyes
onCancelfunctionFunction to be executed when the user cancelsno

Return

Return valueTypeDescriptionDefault value
functionfunctionFunction wrapped around the confirmation logicnull