I am having trouble navigating to the checkout page. Whenever I click on the basket icon in the app, I can see that the URL is changing but the page is not, I always have to refresh the page for the navigation to happen and I am not sure why.
This is my code for App.js:
import React from "react";
import './App.css';
import Header from './Header';
import Home from "./Home";
import { BrowserRouter as Router, Switch, Route}
from "react-router-dom";
import Checkout from "./Checkout";
function App() {
return (
// BEM
<Router>
<div className="app">
<Switch>
<Route path="/checkout">
<Header />
<h1>in checkout</h1>
</Route>
<Route path="/">
<Header />
<Home />
</Route>
</Switch>
</div>
</Router>
);
}
export default App;
I am using these version of react:
"react-dom": "^18.2.0",
"react-router": "^6.4.2",
"react-router-dom": "^5.2.0",
I tried changing the version of react router and it still did not work.