Skip to content

Commit

Permalink
❗️ Perf(JSX) Update dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSvertoka committed Mar 3, 2024
1 parent 280c856 commit 735b17e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/ContactForm/ContactForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ const ContactForm = () => {
if (isInContacts) {
return Notify.warning(`${name} is already in contacts`);
}
dispatch(addContacts({ name, number }));
Notify.success(`New contact added`);
dispatch(addContacts({ name, number }))
.unwrap()
.then(() => {
Notify.success(`New contact added`);
})
.catch(() => {
Notify.failure(`OOPS...`);
});

setName('');
setNumber('');
};
Expand Down

0 comments on commit 735b17e

Please sign in to comment.