1.0.1 • Published 3 years ago

@feca-hooks/use-confirm v1.0.1

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

@feca-hooks/use-confirm

React Hook to create confirm message faster and easier.

How to Install

yarn

yarn add @feca-hooks/use-confirm

npm

npm i @feca-hooks/use-confirm

Usage

Code

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

function App() {
  const onConfirm = () => {
    console.log("submit confirm!");
  }

  const openConfirm = useConfirm("Really?", onConfirm);

  return <button onClick={openConfirm}>Delete Something</button>;
}

Arguments

ArgumentTypeDescriptionRequired
messagestringMessage to show the user on the confirmation propmt.yes
onConfirmfunctionThe callback function executes when the user confirms.yes
onCancelfunctionThe callback function executes when the user cancels.no

Return

Return valueTypeDescription
functionfunctionFunction wrapped around the confirmation logic.
1.0.1

3 years ago

1.0.0

3 years ago