Skip to content
Discussion options

You must be logged in to vote

yeah this is the missing piece: plain router.invalidate() marks the matches invalid: true but it leaves their status as success, so the current match stays resolved and keeps rendering its component (and your useQuery fires) while load() re-runs beforeLoad in the background. that's the brief flash you're seeing.

what you want is to push the matches back into pending so the component unmounts until beforeLoad finishes:

await router.invalidate({ forcePending: true })

forcePending resets matched routes to status: 'pending' and clears their error, so on the re-run the route shows its pendingComponent instead of the stale component, and your redirect in beforeLoad gets to run before anything r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@allan-cannon
Comment options

Answer selected by allan-cannon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants