I am using react-router v6, and I am trying to create routes dynamically from an array, the problem is when I go to any other route like '/tech' for example when I refresh it returns me to the homepage and the URL stays the same. how can I fix that? I want the app to stay on /tech on refresh
<Routes>
{this.state.categories.map((category) => {
return (
<Route
key={category.name}
path={`${
category.name === "all" ? "/" : `${category.name}`
}`}
exact
element={
<PLP/>
}
/>
);
})}
these are all the routes rendered in my app if that is of any help
<Routes>
{this.state.categories.map((category) => {
return (
<Route
key={category.name}
path={`${
category.name === "all" ?"/" : `/${category.name}`}`}
exact
element={<PLP/>}
/>
);})}
<Route
path="/cart"
element={<Cart/>}/>
<Route
path="/pdp/:productID"
element={<PDP/>}
/>
</Routes>