Skip to content

Commit

Permalink
#106 Alert timeout after 2s
Browse files Browse the repository at this point in the history
  • Loading branch information
blms committed Dec 28, 2020
1 parent 88ac709 commit 8cc02e9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/Alerts/Alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ function Alerts({ alerts }) {
for (let i = 0; i < alerts.length; i += 1) {
if (!Object.keys(show).includes(`alert[${i}]`)) {
alertsToAdd[`alert[${i}]`] = true;
setTimeout(() => {
alertsToAdd[`alert[${i}]`] = false;
setShow(
(prevState) => ({ ...prevState, ...alertsToAdd }),
);
}, 2000);
}
}
setShow((prevState) => ({ ...prevState, ...alertsToAdd }));
setShow(
(prevState) => ({ ...prevState, ...alertsToAdd }),
);
}, [alerts]);

return (
Expand Down

0 comments on commit 8cc02e9

Please sign in to comment.