From 74c231b59be1eac08f47009ef89306b0bee90c6f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 2 Oct 2023 12:22:09 -0500 Subject: [PATCH] Stop re-rendering the ScrollTopButton so much --- src/features/notifications/index.tsx | 8 ++++---- src/features/ui/components/timeline.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/features/notifications/index.tsx b/src/features/notifications/index.tsx index 8e62ffd7f..0d9f7f608 100644 --- a/src/features/notifications/index.tsx +++ b/src/features/notifications/index.tsx @@ -104,13 +104,13 @@ const Notifications = () => { }); }; - const handleDequeueNotifications = () => { + const handleDequeueNotifications = useCallback(() => { dispatch(dequeueNotifications()); - }; + }, []); - const handleRefresh = () => { + const handleRefresh = useCallback(() => { return dispatch(expandNotifications()); - }; + }, []); useEffect(() => { handleDequeueNotifications(); diff --git a/src/features/ui/components/timeline.tsx b/src/features/ui/components/timeline.tsx index 051d18122..4db80bf90 100644 --- a/src/features/ui/components/timeline.tsx +++ b/src/features/ui/components/timeline.tsx @@ -38,9 +38,9 @@ const Timeline: React.FC = ({ const hasMore = useAppSelector(state => state.timelines.get(timelineId)?.hasMore === true); const totalQueuedItemsCount = useAppSelector(state => state.timelines.get(timelineId)?.totalQueuedItemsCount || 0); - const handleDequeueTimeline = () => { + const handleDequeueTimeline = useCallback(() => { dispatch(dequeueTimeline(timelineId, onLoadMore)); - }; + }, []); const handleScrollToTop = useCallback(debounce(() => { dispatch(scrollTopTimeline(timelineId, true));