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

171
Vistas
How to navigate between two pages in React JS

I am using React-Router-Dom to navigate between two javascript elements in a create-react-app dapp but when I use it loads the elements on top of the page and just adds the page to the end of the link (localhost/page).

My goal is to have the page reload to the new page on click of the link button with a new background and styling (already done for that page)

App.js Code

<Router>
  <s.Screen>
    <Navbar />
    <Routes>
      <Route path="/MyPandas" element={MyPandas} exact></Route>
    </Routes>
          
    /*
      Rest of Code
    */
</Router>

My other page is just wrapped in a Fragment Component

<Fragment>
  /*
    Code
  */
</Fragment>

 

    
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Assuming your links are working correctly, and it seems they are if the URL in the address bar updates to "/MyPandas".

The issue is that the element prop isn't passed a correct value. react-router-dom@6 Route component's element prop takes a ReactNode, a.k.a. JSX, not a reference to a React component. Pass <MyPandas /> instead of MyPandas.

<Route path="/MyPandas" element={<MyPandas />} />

Note: There's no need for the exact prop. Not only does it not exist in the RRDv6 Route component API, but all routes are now always exactly matched.

about 4 years ago · Juan Pablo Isaza Denunciar

0

use exact in your Routes e.g : <Route path='/products' exact>

about 4 years ago · Juan Pablo Isaza 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