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

182
Visualizações
React title changing based on domain

I have 2 domains in my React project that works like, "develop.something.com" and "develop.somethingnew.com". Currently both the domains taking the index.html file's title. But, now I want to set the separate individual titles for both the domains via the array methods or via the other methods when they are appeared on the UI. How should I go about implementing this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Based on window.location object (which has the host name details) you can set the title

function buildTitle(href) {
  const titles = {
    "develop.something.com": "Some title",
    "develop.somethingnew.com": "New Title",
  };
  const key = Object.keys(titles).find((t) => href.includes(t));
  return key ? titles[key] : "Default title";
}

function updateTtile(title) {
  window.document.title = title;
}

// In the component
updateTitle(buildTitle(window.location.href));
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