Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

77
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda