'React-Router-Dom V6 Nested URL Not working

Can I get help actually i upgraded my react-router-dom to V6 So i fixed the main url It works but the url with nested link doesn't

Example /about works But /about-item/1 doesn'tenter image description here

Code :



Solution 1:[1]

You can use it like that:

              <Route
                path="service"
                element={<ServicePage />}
              >
                <Route
                  path="service-details/:id"
                  element={<ServiceDetails />}
                />
                <Route
                  path="service-details/new"
                  element={<ServiceDetails />}
                />  
             </Route>

And don't forget to use <Outlet/> tag in the ServicePage component

Solution 2:[2]

  1. First you can uninstall. -npm uninstall react-router-dom

  2. Install this version. -npm install [email protected]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ar26
Solution 2 Gaurav Gupta