Why is useLocation's return object different from window.location? #11170
Unanswered
zakariaelas
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello team!
I'm wondering why the object returned from the useLocation hook has properties that differ from the window.location object, despite them having the same name, and me expecting that they would indeed refer to the same things. For example, assume the following URL:
https://example.com/#/foo
When using react-router's HashRouter, I'd expect reactRouterLocationObj.hash to equal window.location.hash, but this is not true since:
''
#/foo
I have a stackblitz demo to replicate if anyone wants to play around with it.
Any pointers to what I might be missing here?
Beta Was this translation helpful? Give feedback.
All reactions