Expose navigation action type (PUSH, REPLACE, BACK, FORWARD, or GO) in router state and loaders. #8262
YakuBrangJa
started this conversation in
Ideas
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.
Router internally knows how a navigation was performed (PUSH, REPLACE, BACK, FORWARD, or GO) But the value is not accessible through router.state, beforeLoad, or loader functions.
Use case
Example a newsfeed route with an infinite query:
const feedQuery = useInfiniteQuery(postQueries.feed())I want the following behavior:
<Link>or navigate() → reset the infinite query and fetch fresh data (require knowledge of navigation action type)The only way you can access the action type state is by subscribing the router.history. Which is not very feasible to implement route scoped logic right now.
// Dev tool console log { "action": { "type": "PUSH" // THIS VALUE NEED TO BE EXPOSED } "location": { "href": "/", "pathname": "/", "hash": "", "search": "", "state": { "__hashScrollIntoViewOptions": true, "key": "hca89", "__TSR_key": "hca89", "__TSR_index": 2 } }, }Current workaround I've
All reactions