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

199
Visualizações
Unable to visit pages in react router dom v6?

I am trying to a create router. I works for home page but when i goto other page like /btn its not working.

The error is Cannot GET /btn.

I tried this with Switch and Routes components but not working.

Code:-

class App extends React.Component {
  constructor(props) {
    super(props);
  }

  toggleBtn = () => {
    console.log("Hello World!");
  };

  render() {
    return (
      <Router>
        <Suspense fallback={<div>...Loading</div>}>
          <Routes>
            <Route
              exact
              path="/"
              element={<SimpleBtn toggleBtn={this.toggleBtn} />}
            />
            <Route exact path="/btn">
              <SimpleBtn2 toggleBtn={this.toggleBtn} />
            </Route>
          </Routes>
        </Suspense>
      </Router>
    );
  }
}

I almost wrote code as in react docs but it didn't solve the problem.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

This is a server side issue. You need to add support for HTML5 Push State to the server. If youre using create-react-app this will just work out of the box.

about 4 years ago · Santiago Gelvez 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