Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
How to log window.scrollY value on console with next js?

For some reason my ScrollToTop component is not working as expected in my app. I have tried to debug the matter in all ways that i know but i cannot figure out why the component do not log value of scrollY as expected. I tried to move the snippet below in other component of my app but same result. I tried to call the toggleVisibilty function but it only log 0 once then nothing else. Can someone tell me what can cause such error, please? thanks

 const toggleVisibility = () => {
      console.log(window.scrollY)
      // window.pageYOffset >= 300 ?
      // setisVisible(true) :
    
      // setisVisible(false)
      // console.log(window.pageYOffset)      
    };
    //toggleVisibility()
    // const scrollToTop = () => {
    //   window.scrollTo({
    //       top:0,
    //       behavior: "smooth",
    //   });
    // };
    
    useEffect(() => {
      window.addEventListener('scroll', toggleVisibility, {passive: true});
      return () => window.removeEventListener('scroll', toggleVisibility);
      
    
    });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found what was my mistake. my html and body had a height property rather than a min-height in my css file. When changed this it worked fine.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda