Closed anacierdem closed 2 years ago
Ok there is already RouteSubscriber to listen to route changes.
Even better we provide a createRouterSelector
that allows you to create hooks that re-render only when specific parts of the router state change (like location). So you can easily build your own, optimised useLocation hook
I think a router library should provide a mechanism to track the route history. Latest react-router have the
useLocation
hook to listen for route changes, which you can then push onto a stack if you like.Either, we should have a mechanism to inspect the current history stack (no need for write access - just inspection) or a similar hook to listen for all route changes.
The ability to listen to changes is not very useful for implementing breadcrumbs for example so inspecting the history is the better API in my opinion.
Is there a practical way of listening to all route changes or preferably inspecting history with the current API?