UNPKG

@am-hooks/use-confirm

Version:

When the user clicks the delete button, show the message before firing the event

18 lines (17 loc) 469 B
export const useConfirm = (message = "", onConfirm, onCancel) => { if (!onConfirm || typeof onConfirm !== "function"){ return; } if (!onCancel || typeof onCancel !== "function"){ return; } const confirmAction = () => { // window.confirm or confirm 적기 if (window.confirm(message)) { onConfirm(); } else { onCancel(); } }; return confirmAction; };