Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!