router
router copied to clipboard
`onStay` property should use current matches, not previous
Describe the bug
When I change url params on page via navigate like this
const router = useRouter()
const handleButtonClick = (pageNumber: number) => {
router.navigate({ search: { page: pageNumber }, replace: true })
}
In onStay callback i got page number from params before navigate call
onStay: (match) => {
console.log('onStay page number', match.search.page)
},
Maybe the problem is here - stayingMatches should filter newMatches instead of previousMatches?
Your Example Website or App
https://github.com/finnan444/tanstack-router-on-stay-error
Steps to Reproduce the Bug or Issue
- Go to about page
- Click "Go to next page"
- Url will be updated, but in console you will see that the page number equals the one in url -1
Expected behavior
I expect the match to be equal to current route search params
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Chrome
- Version: 126.0.6478.127
Additional context
No response