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

228
Views
Scroll to an Anchor Link on a React App Using a Link on an External Page

I have an external page with links that point back to my main react application using anchor tags. (ex: External page has a link to app/#platform).

I've been trying to find a way to make the page scroll to this anchor but have had no luck. The issue, I think, is that the anchors don't exist until the page renders.

When clicking links on the React App to the anchor tags -- everything works fine. The issue is in navigating from outside the React app.

I'm using React V18 and React Router V6.

My current best stab is in adding a useEffect that catches the hash and attempts to scroll. But it's not working either.

  useEffect(() => {

    const element = document.getElementById(location.hash);

    setTimeout(() => {
      window.scrollTo({
        behavior: element ? "smooth" : "auto",
        top: element ? element.offsetTop : 0
      });
     }, 100);
    }, [location]);
about 4 years ago · Juan Pablo Isaza
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!