1.0.0 • Published 9 months ago

@smooks/use-confirm v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@smooks/use-confirm

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

Installation

yarn

yarn add @smooks/use-confirm

npm

npm i @smooks/use-confirm

Usage

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

Argument

ArgumentTypeDescriptionRequired
messagestringMessage to show the user on the confirmation promptyes
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.0

9 months ago