From 0a9b4b6388ac9718aad44b075c6bbf4bc2095521 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Tue, 11 Jan 2022 11:31:42 +0700 Subject: [PATCH] fixed getScrollHeight --- src/hooks/dom/useScrollHeight.ts | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/hooks/dom/useScrollHeight.ts b/src/hooks/dom/useScrollHeight.ts index 80596fec..48bf7f4d 100644 --- a/src/hooks/dom/useScrollHeight.ts +++ b/src/hooks/dom/useScrollHeight.ts @@ -1,5 +1,3 @@ -import { useEffect, useState } from 'react'; - const getHeight = () => { if (typeof document === 'undefined') { return 0; @@ -16,20 +14,4 @@ const getHeight = () => { html.offsetHeight ); }; -export const useScrollHeight = () => { - const [scrollHeight, setScrollHeight] = useState(getHeight()); - - useEffect(() => { - const measure = () => setScrollHeight(getHeight()); - - window.addEventListener('scroll', measure); - window.addEventListener('resize', measure); - - return () => { - window.removeEventListener('scroll', measure); - window.removeEventListener('resize', measure); - }; - }, []); - - return scrollHeight; -}; +export const useScrollHeight = () => getHeight();