@gitgw/use-confirm

1.0.5 • Public • Published

@gitgw/use-confirm

React Hook to prompt a confirmation before executing a function.

Installation

npm

npm i @gitgw/use-confirm

yarn

yarn add @gitgw/use-confirm

Usage

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

function App() {
  const onConfirm = () => {
    console.log("onConfirm");
  }
  const onCancel = () => {
    console.log("onCancel");
  }

  const confirmAction = useConfirm("true or false?", onConfirm, onCancel);
  
  return (
    <div className="App">
      <button onClick={confirmAction}>confirmAction</button>;
    </div>
  );
}

Arguments

Argument Type Description Required
message String Message to show the user on the confirmation propmt yes
onConfirm Function Function to be executed when the user confirms yes
onCancel Function Function to be executed when the user cancels yes

Return

Return value Type Description Default value
Function Function Function wrapped around the confirmation logic null

Package Sidebar

Install

npm i @gitgw/use-confirm

Weekly Downloads

8

Version

1.0.5

License

MIT

Unpacked Size

2.19 kB

Total Files

4

Last publish

Collaborators

  • githubgw