TanStackT
TanStack7mo ago
8 replies
spotty-amber

Is there a way to `navigate` or go `back` when the next location matches the previous location?

Sometimes we want the next navigation to use back to clean up the history stack.

The implementation we have is to track the last location with useLocation and intercept calls to navigate and use history.back instead but it requires:
- interpolating the NavigateOptions like to, params, ...
- tracking the last location with useLocation and an effect

The above works but I'm wondering if we've missed something in the actual navigate api or a better way than tracking the last location with useLocation.
Was this page helpful?