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

116
Visualizações
React Routing: URL is changing but the components remain same

I have simplified my problem. When I try to navigate through the nav-bar, url changes but the component remains the same. I am new to React, and have trouble with routing. I used the latest version of "react-router-dom" where Switch was not working, so I went back to the version 5.2.0. I could use Switch there but the problem remained. I have tried a lot but all in vain. If there is an efficient and easy way of routing this, please help me with that. Thanks

App.js

import './App.css';
import React from "react";
import {
    BrowserRouter as Router,
    Switch,
    Route,
    Link
} from "react-router-dom";

function App() {
    return (
        <Router>

            <nav>
                <Link to="/">Home</Link> <br />
                <Link to="/about">About</Link>
            </nav>

            <Switch>
                <Route exact path="/" render={() => {
                    return (<> This is home page </>)
                }}>
                </Route>
                <Route exact path="/about" render={() => {
                    return (<> This is about </>)
                }}>
                </Route>
            </Switch>

        </Router>
    );
}
export default App;
about 4 years ago · Juan Pablo Isaza
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