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

83
Vistas
React Scroll to top not working? New solutions needed

So I'm trying to scroll to the top of the screen when the user submits a form. The answers on stacked overflow don't seem to work for me.

here's my code:

handleClick (evt) {
    evt.preventDefault();
    this.calculateScore();
    this.setState({submittingQuiz: true});

    // let myPage = document.querySelector('body');
    // myPage.scrollTo(0,0); Couldn't get this way to work either

    window.scrollTo({top: 0, behavior: 'smooth'})
}

Any thoughts on how to fix this problem. I have some styling I think may be messing with it..

html {
  background-image: url('./tupac.jpeg');
  background-position-y: -580px;
  background-repeat: no-repeat;
  background-size: cover;
  overflow: hidden;
}

Anyone got a clue?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This probably happens because the body has a height: 100vh; or some main container of the application has the same height: 100vh;

Try remove height: 100vh; on body and the main container of the application and test it again.

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