From 688c4a0071fde8cb60e1575c2c74498abb9c639e Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 16 Feb 2021 09:39:46 +0100 Subject: [PATCH] use patternfly timout instead of own impl (#361) --- src/components/alert/AlertPanel.tsx | 1 + src/components/alert/Alerts.tsx | 22 +--------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/components/alert/AlertPanel.tsx b/src/components/alert/AlertPanel.tsx index 64b12164a0..b84fa95331 100644 --- a/src/components/alert/AlertPanel.tsx +++ b/src/components/alert/AlertPanel.tsx @@ -24,6 +24,7 @@ export function AlertPanel({ alerts, onCloseAlert }: AlertPanelProps) { { const [alerts, setAlerts] = useState([]); - const [timers, setTimers] = useState([]); - - useEffect(() => { - const timersKeys = timers.map((timer) => timer.key); - const timeOuts = alerts - .filter((alert) => !timersKeys.includes(alert.key)) - .map((alert) => { - const timeOut = setTimeout(() => hideAlert(alert.key), 8000); - return { key: alert.key, timeOut }; - }); - setTimers([...timers, ...timeOuts]); - return () => timers.forEach((timer) => clearTimeout(timer.timeOut)); - }, [alerts]); const createId = () => new Date().getTime(); const hideAlert = (key: number) => { setAlerts((alerts) => [...alerts.filter((el) => el.key !== key)]); - setTimers((timers) => [...timers.filter((timer) => timer.key === key)]); }; const addAlert = (