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

198
Views
In react component, location.href doesnt seem to redirect

I have a very simple scenario in which I need to redirect to an external domain in react something like this on change of a switch:

handleSwitch={() => {
                location.href = 'https://www.google.com/'; // oldAppUrl;
                    // window.open(oldAppUrl, '_href')
                }}

However, this is not working. What am I missing?

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

0

Try like this:

window.location.href = 'https://www.google.com/';

and this should work too, using it in an app:

window.location = 'https://www.google.com/';

If none of these two works it means your handleSwitch function is probably not called, then you should show us some more code to help with the solving.

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!