Because the route parameter is missing from the useEffect dependency array, so the effect does not re-run when the id changes. Add the id to the array so the fetch re-runs on every navigation.
Common React Router Mistakes That Break Navigation in React Apps
Why does my dynamic route show stale data after navigation?
The answer
More FAQs in Common React Router Mistakes That Break Navigation in React Apps
Because plain anchor tags trigger a full page reload, which loses app state and defeats the single-page purpose. Link updates the URL without a reload, which is what makes client-side routing work.
Because you forgot to wrap your app in a BrowserRouter at the root. Without a router context, Routes and Links have nothing to connect to and throw errors or do nothing.
Because you are missing a catch-all 404 route at the end of your Routes. Add one that renders a not-found component, so invalid URLs are handled gracefully instead of showing nothing.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.