From 6f6ad998b027560ee429d50db3831d64b1ec3559 Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Wed, 3 Jan 2024 21:34:33 +1300 Subject: [PATCH] useRef initial state --- src/js/views/Modals/KioskMode.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/views/Modals/KioskMode.js b/src/js/views/Modals/KioskMode.js index 3cb4e168a..45c20fec6 100755 --- a/src/js/views/Modals/KioskMode.js +++ b/src/js/views/Modals/KioskMode.js @@ -17,15 +17,15 @@ const LyricsScroller = ({ content = '', percent = 0, }) => { - const containerRef = useRef({}); - const contentRef = useRef({}); + const containerRef = useRef(null); + const contentRef = useRef(null); const [autoScroll, setAutoScroll] = useState(true); const onWheel = () => setAutoScroll(false); useEffect(() => { if (autoScroll) { - const scrollable = contentRef.current?.scrollHeight - containerRef.current.clientHeight; - containerRef.current.scrollTo(0, percent * scrollable) + const height = (contentRef.current?.scrollHeight - containerRef.current?.clientHeight) || 0; + containerRef.current.scrollTo(0, percent * height) } }, [percent]);