The issue is the ProdDetails component is not called when it is nested (products/:id). Even though the URL changes on the address bar, No changes in UI
Here is App.tsx
function App() {
return (
<div className="App">
<Routes>
<Route path='/' element={<Home />} />
<Route path='products' element={<ProdList />} >
<Route path=":id" element={<ProdDetails />} />
</Route>
</Routes>
</div>
);
}
The ProdList component
const ProdList: React.FC = () => {
const [prods, setProdList] = useState<IProducts>([])
useEffect(() => {
ProdAPI.getAll()
.then((list: IProducts) => {
setProdList(list)
})
}, [])
return(
<div>
<div>
{prods.map((prod) => (
<li key={(prod.id).toString()}>
<Link to={(prod.id).toString()}>
{prod.title}
</Link>
</li>
))}
</div>
</div>
)
}
export default ProdList
It works when it is not nested. What is the reason for that?