I wrote the Routes in my project as below:
<Routes>
<Route exact path="/" element={<Home />} />
<Route exact path='/login' element={<Login />} />
<Route exact path='/about' element={<About />} />
<Route exact path='/store' element={<Store />} />
<Route exact path='/store/:productID' element={<Product />} />
<Route path={['/not-found', '*']} element={<NotFound />} />
</Routes>
In Product
page I want to display the existing product ids and redirect the other ones to not-found page:
{!check && navigate("/not-found", {replace: true})}
<div className="container">
<ul>
<li>Product ID: {productID}</li>
<li>Name: {check.name}</li>
<li>Price: {check.price}</li>
<li><img src={check.image} /></li>
</ul>
</div>
but I'm getting this error:
Uncaught TypeError: meta.relativePath.startsWith is not a function
I also wrote it with navigate component:
{!check && <Navigate to="/not-found" />}
Still displays a white page for not existing ids.