Recently, I have been working on ReactJS. I use React Router Dom package for page navigation. I created custom Breadcrumb links for navigation in which I used Link component from React Router Dom package.
While working on breadcrumb, I faced a problem. I found that when link is clicked the link in browser was changed but page itself did not redirect to the linked page. Code for BreadCrumb and App components are shown below.
BreadCrumb.tsx
This is the main BreadCrumb component which is being referred in other components.
Main App.tsx
Usage of BreadCrumb
After digging, I found the problem. The problem was <Router> was being added twice. The first time it was being added in **App.tsx** and second time inside` BreadCrumb.tsx. So, the solution is to take out wrapper Router from Breadcrumb component. There should only be one wrapper of <Router>. So that final BreadCrumb.tsx looks like as shown below.
Compare the code snippet before and after the removal of <Router> and you’ll see the difference. Hope this helps you some hour of digging to spot the problem.