router
router copied to clipboard
<Link to="."> navigates to parent location when it is in a parent route
Describe the bug
I have a Link like this:
<Link to="." search={{ someParams: true }}>My link</Link>
According to the documentation, it should navigate to current location + ?someParams=true.
e.g.: /foobar?someParams=true if my current location is /foobar
However, when this link is in a parent route, it navigates to the parent location instead of staying on the same location (see the example app).
Your Example Website or App
https://stackblitz.com/edit/react-ts-cqow59?file=index.tsx
Steps to Reproduce the Bug or Issue
- Click on "Goto foo"
- Click on the "Stay here and add params" INSIDE the Foo child -> it stays on the current location
- Click on the "Stay here and add params" OUTSIDE the Foo child -> it navigates to "."
Expected behavior
<Link to="."> should always stay on the current location, wherever it is in the React tree.
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response