Skip to content

Commit

Permalink
TW-1166 Memoize a callback for useTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
keshan3262 committed Nov 14, 2023
1 parent 530cd7b commit 55e5939
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/notifications/components/notifications/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';

import { useDispatch } from 'react-redux';

Expand All @@ -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 (
Expand Down

0 comments on commit 55e5939

Please sign in to comment.