Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda