From 99deec9d247f640562f612a82cda1965a76012cf Mon Sep 17 00:00:00 2001 From: ITurres Date: Sun, 10 Mar 2024 00:01:49 -0300 Subject: [PATCH 01/15] Fix: clean up event listener and add aria-hidden to true at 'LineCount.tsx' --- src/components/UI/LineCount.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/UI/LineCount.tsx b/src/components/UI/LineCount.tsx index 4d756b3..2abebff 100644 --- a/src/components/UI/LineCount.tsx +++ b/src/components/UI/LineCount.tsx @@ -3,18 +3,25 @@ import React, { useEffect, useState } from 'react'; const LineCount: React.FC = () => { const [windowHeight, setWindowHeight] = useState(window.innerHeight); const spanHeight = 24; // ? 24px. - const lines = Math.round(windowHeight / spanHeight); + // ? rounds to ensure that 'line' is always an integer. // !important to prevent >>RangeError: Invalid array length<< + const lines = Math.round(windowHeight / spanHeight); useEffect(() => { window.addEventListener('resize', () => { setWindowHeight(window.innerHeight); }); + + return () => { + window.removeEventListener('resize', () => { + setWindowHeight(window.innerHeight); + }); + }; }, []); return ( -
+