diff --git a/app/(main)/quiz/layout.tsx b/app/(main)/quiz/layout.tsx index 36f4bcd..78f961f 100644 --- a/app/(main)/quiz/layout.tsx +++ b/app/(main)/quiz/layout.tsx @@ -1,45 +1,13 @@ -'use client'; import ScrollToTop from '@/components/global/ScrollToTop'; import useScrollToTop from '@/lib/hooks/useScrollToTop'; import { cn } from '@/lib/utils'; import { ChevronUp } from 'lucide-react'; -import React, { PropsWithChildren, useEffect, useState } from 'react'; +import React, { PropsWithChildren } from 'react'; const layout = ({ children }: PropsWithChildren) => { - const [clicked, setClicked] = useState(0); - - useEffect(() => { - window.scrollTo(0, 0); - console.log('first'); - }, [clicked]); - - const [scrollY, setScrollY] = useState(false); - - const handleScroll = () => { - setScrollY(window.scrollY > 500 ? true : false); - }; - - useEffect(() => { - window.addEventListener('scroll', handleScroll); - - return () => { - window.removeEventListener('scroll', handleScroll); - }; - }, []); - return ( -
-
setClicked((prev) => prev + 1)}> - -
+
+ {children}
diff --git a/app/layout.tsx b/app/layout.tsx index 58a33b7..f15cec2 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -50,7 +50,7 @@ export default function RootLayout({ children }: IProps) { - + {children} diff --git a/components/global/ScrollToTop.tsx b/components/global/ScrollToTop.tsx index 7b0a343..753b5bb 100644 --- a/components/global/ScrollToTop.tsx +++ b/components/global/ScrollToTop.tsx @@ -19,6 +19,13 @@ const ScrollToTop = () => { }; }, []); + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth', + }); + }; + return (
{ 'opacity-100 pointer-events-auto': scrollY, 'opacity-0 pointer-events-none': !scrollY, }, - )}> + )} + onClick={scrollToTop}>
);