From d1c0a27e7a5b0dc2653a6859fe312af2eea54445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Tue, 26 Sep 2023 12:54:17 +0200 Subject: [PATCH] Replace isScrolling state with ref --- src/components/Hoverable/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Hoverable/index.js b/src/components/Hoverable/index.js index aa28122e3e2e..eff165870048 100644 --- a/src/components/Hoverable/index.js +++ b/src/components/Hoverable/index.js @@ -25,8 +25,8 @@ function mapChildren(children, callbackParam) { function InnerHoverable({disabled, onHoverIn, onHoverOut, children, shouldHandleScroll}, outerRef) { const [isHovered, setIsHovered] = useState(false); - const [isScrolling, setIsScrolling] = useState(false); + const isScrolling = useRef(false); const isHoveredRef = useRef(false); const ref = useRef(null); @@ -38,12 +38,12 @@ function InnerHoverable({disabled, onHoverIn, onHoverOut, children, shouldHandle isHoveredRef.current = hovered; - if (shouldHandleScroll && isScrolling) { + if (shouldHandleScroll && isScrolling.current) { return; } setIsHovered(hovered); }, - [disabled, shouldHandleScroll, isScrolling], + [disabled, shouldHandleScroll], ); useEffect(() => { @@ -60,7 +60,7 @@ function InnerHoverable({disabled, onHoverIn, onHoverOut, children, shouldHandle } const scrollingListener = DeviceEventEmitter.addListener(CONST.EVENTS.SCROLLING, (scrolling) => { - setIsScrolling(scrolling); + isScrolling.current = scrolling; if (!scrolling) { setIsHovered(isHoveredRef.current); }