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

207
Views
Use ScrollToTop in react (but not for every link - how to do it)

I need to use ScrollToTop, but not for every link. What is the best way to do this? Adding a function to every link where I want to use this function seems like the wrong way. I was also thinking about wrapping all components <ScrollToTop>(all components and routes)</ScrollToTop> and excluding only the places where I don't want to use it - just not sure how to do that. I've tried to find the answer, but I guess no one has asked this, or I can't find it.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If I understand your question, you can create a Higher order component which has this ScrollToTop functionality. See here

about 4 years ago · Juan Pablo Isaza Report

0

Try it

let scrollToTop = () =>{window.scrollTo(0,0)}

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!