0
0 Comments

Im getting error No routes matched location “/product%22nike-slim-shirt” this and I cant solve can you help me please?

my App looks like this

import { BrowserRouter, Link, Route, Routes } from ‘react-router-dom’;
import HomeScreen from ‘./screens/HomeScreen’;
import ProductScreen from ‘./screens/ProductScreen’;
function App() {
  return (
    <BrowserRouter>
      <div>
        <header>
          <Link to=”/”>amazona</Link>
        </header>
        <main>
          <Routes>
            <Route path=”/product/:slug” element={<ProductScreen />}></Route>
            <Route path=”/” element={<HomeScreen />}></Route>
          </Routes>
        </main>
      </div>
    </BrowserRouter>
  );
}
export default App;

/*********/
and my ProductScreen look like this

import { useParams } from ‘react-router-dom’;
function ProductScreen() {
  const params = useParams();
  const { slug } = params;
  return (
    <div>
      <h1>{slug}</h1>
    </div>
  );
}
export default ProductScreen;

Basir Changed status to publish October 11, 2022