T
TanStack15mo ago
rare-sapphire

Syncronously getting url

I would like to sycnronously get the current url.
My use case is this. I have a form submit to a database that may take some time to resolve. When the request resolves I navigate the user to a new page. But, if while the request is resolving (could take a few seconds) the user manually navigates to another page in the app, I don't want to navigate them to the new page when the request resolves.
Since the value returned from useLocation is stateful, it's value is stale if the user manually navigates while the request is resolving. Is there a way to call getLocation once the request resolves so I can check if the user has navigated while the request was resolving?
2 Replies
helpful-purple
helpful-purple15mo ago
you could read window.location ?
rare-sapphire
rare-sapphireOP15mo ago
yeah, I'm thinking about that. I was wondering if there was a non-stateful way to get the url from tanstack router. But that would totally work.

Did you find this page helpful?