'use client' import { useEffect, useState } from 'react' export default function ScrollToTop() { const [visible, setVisible] = useState(false) useEffect(() => { const onScroll = () => { const scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 setVisible(scrollTop > 130) } window.addEventListener('scroll', onScroll, { passive: true }) return () => window.removeEventListener('scroll', onScroll) }, []) if (!visible) return null return ( ) }