-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: useHref after the 6.19 update returns a different path than in 6.18 #11070
Comments
Could you provide a small codesandbox reproduction of this setup so we can be sure we're looking at the right thing? Do you have a splat route in your app allowing the sub-Routes to be used? Here's a sandbox you can fork to get started: https://codesandbox.io/p/sandbox/react-router-dom-template-fglmrh |
here is example codesandbox but I couldn't display JSON.stringify(href) in the Subpage component because codesandebox somehow doesn't respond to the url change in the example but please try to edit the url in the example like this from and this url will show useHref('') as |
I'm not sure this is reproducing the issue? If I download that sandbox and run it locally, I see Here's a simplified sandbox with a link to the If we can get a reproduction together I think this is likely a dup of #11052, the original issue didn't reflect the splat route so I wasn't sure at first but the codesandbox is using the splat. |
I can't explain it somehow, in our application version I will try to go through our application and find out in more detail why it is done this way. In any case, based on the given example in codesandbox, is the correct behavior as it is in version 6.20? thanks |
Technically speaking, I believe the behavior in 6.20 is correct (based on the bug fix in #10983) - there's a longer explanation in #11052 (comment). However, it does seem that a number of folks may have been relying on the buggy behavior so we are planning to take a closer look, so I would stay on 6.18.0 and hold off on making changes to work with the new behavior until we land on a decision there. The tl;dr; of the issue is that IMO if you are on URL |
I'm going to close this out as a dup of #11052 since I'm almost certain that's the underlying cause. Please add any reproduction if you can come up with it and if it turns out to be a different underlying cause we can re-open this 👍 |
What version of React Router are you using?
6.20
Steps to Reproduce
for example
url: http://myApp.com
url: http://myApp.com/abc/2
url: http://myApp.com/abc/2/example
on href value is
'/abc/2/example'
but in version 6.18 is value/abc/2
how do I get the value of /abc/2, i.e. parent route in Routes positioned in the App component ?
Expected Behavior
useHref('')
returns the value/abc/2
Actual Behavior
useHref('')
returns the values/abc/2/example
The text was updated successfully, but these errors were encountered: