react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Docs]: description of relative link behavior is incorrect for index routes

Open max-dekock opened this issue 1 year ago • 1 comments

Describe what's incorrect/missing in the documentation

In the Link documentation, relative paths are explained thusly:

By default, links are relative to the route hierarchy (relative="route"), so .. will go up one Route level from the current contextual route.

This description is incorrect, as it doesn't account for the fact that index routes (and any routes that don't add to the path) are passed over.

I had some routes that looked something like this:

<Route path="module">
  <Route index element={<FeatureA/>}/>
  <Route path="feature-a" element={<FeatureA/>}/>
  <Route path="feature-b" element={<FeatureB/>}/>
  {...}
 </Route>

I expected that relative links in the index route would work the same as in the feature-a path. I was confused why they were broken, until I stumbled upon issue #8350 and realized that there was an undocumented change making index routes behave differently.

The documentation should be changed to reflect this behavior.

max-dekock avatar Oct 11 '24 18:10 max-dekock

Thank you for noticing this issue! I have added the missing part

OlegDev1 avatar Oct 17 '24 14:10 OlegDev1