1.0.1 • Published 4 years ago

@lchooks/use-confirm v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

@lchooks/use-confirm

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

노마드코더 수업을 들으면서 클론코딩했습니다. Thank you nomadcoders!! https://academy.nomadcoders.co/p/introduction-to-react-hooks

Installation

yarn

yarn add @lchooks/use-confirm

npm

npm i @lchooks/use-confirm

Usage

import React from "react";
import useConfirm from "@lchooks/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
1.0.1

4 years ago

1.0.0

4 years ago