Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Reaccionar: la URL se actualiza pero no la página que usa rutas

Estaba tratando de crear este sitio web. Todas las páginas se muestran bien, pero usando el enrutamiento, quería pasar de una página a otra usando clics. Si actualizo manualmente la url y vuelvo a cargar o presiono enter, la página se vuelve a cargar, pero si hago clic en un componente que lleva a otro componente, la url cambia pero la página sigue siendo la misma. La gente decía que bajara a la historia 4.10.1. La degradación no parece ayudar. Por favor echa un vistazo.

 import Topbar from "./components/topbar/Topbar"; import Home from "./pages/home/Home" import Login from "./pages/login/Login"; import Register from "./pages/register/Register"; import Settings from "./pages/settings/Settings"; import Write from "./pages/Write/Write"; import SinglePost from "./pages/singlePost/SinglePost"; import { BrowserRouter as Router, Switch, Route } from "react-router-dom"; import { withRouter } from "react-router-dom/cjs/react-router-dom.min"; function App() { const currentUser = false; return ( <Router> <Topbar /> <Switch> {/* when only "/" is called then only home should be called ie why we did exact*/} <Route exact path="/" component={<Home />} /> <Route path="/posts"> <Home /> </Route> {/* If user is registered then send to homepage else send to register page */} <Route exact path="/register"> {currentUser ? <Home /> : <Register />} </Route> {/* If user is logged in then send to homepage else send to login page */} <Route exact path="/login"> {currentUser ? <Home /> : <Login />} </Route> {/* Open a single post which has a unique id which can uniquely identify that post. eg post/123 */} <Route exact path="/post/:id"> <SinglePost /> </Route> {/* If user exits then send to write page else send to login page */} <Route exact path="/write"> {currentUser ? <Write /> : <Login />} </Route> <Route exact path="/settings"> {currentUser ? <Settings /> : <Login />} </Route> </Switch> </Router> ); } export default App;

Aquí está la configuración json

 "history": "4.10.1", "react": "^18.1.0", "react-dom": "^18.1.0", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", "react-scripts": "5.0.1", "redux": "^4.0.5", "web-vitals": "^2.1.4"
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!