From b0ab02bedf61d1e4df8572a146777a4d5079ffd6 Mon Sep 17 00:00:00 2001 From: Pujan Date: Thu, 3 Aug 2023 17:43:04 +0530 Subject: [PATCH] added useCallback for scrollToBottom --- src/hooks/useReportScrollManager/index.native.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/useReportScrollManager/index.native.js b/src/hooks/useReportScrollManager/index.native.js index e206991efa03..35af064cb062 100644 --- a/src/hooks/useReportScrollManager/index.native.js +++ b/src/hooks/useReportScrollManager/index.native.js @@ -1,4 +1,4 @@ -import {useContext} from 'react'; +import {useContext, useCallback} from 'react'; import ReportScreenContext from '../../pages/home/ReportScreenContext'; function useReportScrollManager() { @@ -20,13 +20,13 @@ function useReportScrollManager() { /** * Scroll to the bottom of the flatlist. */ - const scrollToBottom = () => { + const scrollToBottom = useCallback(() => { if (!flatListRef.current) { return; } flatListRef.current.scrollToOffset({animated: false, offset: 0}); - }; + }, [flatListRef]); return {ref: flatListRef, scrollToIndex, scrollToBottom}; }