From 5c4c0cebde2d12143e70d0c7fa344419835a0706 Mon Sep 17 00:00:00 2001 From: Eliamar Tani Date: Sun, 1 Nov 2020 13:55:43 +0000 Subject: [PATCH] Update code to follow dry principle --- components/core/Layout/Layout.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/core/Layout/Layout.tsx b/components/core/Layout/Layout.tsx index 9ac0a74ed..c1ec2e896 100644 --- a/components/core/Layout/Layout.tsx +++ b/components/core/Layout/Layout.tsx @@ -40,8 +40,9 @@ const Layout: FC = ({ children, pageProps }) => { debounce(() => { const offset = 0 const { scrollTop } = document.documentElement - if (scrollTop > offset) setHasScrolled(true) - else setHasScrolled(false) + const scrolled = scrollTop > offset + + setHasScrolled(scrolled) }, 1) }, [])