Skip to content

Commit

Permalink
Optimized confirmation and close modal functions using useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavgoel29 committed Nov 23, 2024
1 parent a5b77bb commit 5709f02
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/Misc/DeleteOrResetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ const DeleteOrResetModal = ({
}, []);

// Function to validate and trigger confirmation logic
const tryConfirm = () => {
const tryConfirm = useCallback(() => {
if (type === 'simple' || confirmationText === confirmText) {
setConfirmText('');
onConfirm();
}
};
}, [type, confirmationText, confirmText, onConfirm]);

// Function to close the modal and reset the confirmation text state.
const closeModal = () => {
const closeModal = useCallback(() => {
setConfirmText('');
onClose();
};
}, [onClose]);

return (
<Modal
Expand Down

0 comments on commit 5709f02

Please sign in to comment.