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

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

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 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