From 55e5939e27a6789612214fc43f5e897442ef8fdf Mon Sep 17 00:00:00 2001 From: Inokentii Mazhara Date: Tue, 14 Nov 2023 15:24:22 +0200 Subject: [PATCH] TW-1166 Memoize a callback for useTimeout --- src/lib/notifications/components/notifications/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/notifications/components/notifications/index.tsx b/src/lib/notifications/components/notifications/index.tsx index fea457aa83..e5ac180368 100644 --- a/src/lib/notifications/components/notifications/index.tsx +++ b/src/lib/notifications/components/notifications/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback } from 'react'; import { useDispatch } from 'react-redux'; @@ -24,7 +24,9 @@ export const Notifications = () => { const isEnabledAdsBanner = useIsEnabledAdsBannerSelector(); const shouldShowPartnersPromoState = useShouldShowPartnersPromoSelector(); - useTimeout(() => void dispatch(viewAllNotificationsAction()), VIEW_ALL_NOTIFICATIONS_TIMEOUT, true, [notifications]); + const viewAllNotifications = useCallback(() => void dispatch(viewAllNotificationsAction()), [dispatch]); + + useTimeout(viewAllNotifications, VIEW_ALL_NOTIFICATIONS_TIMEOUT, true, [notifications]); useLoadPartnersPromo(); return (