Skip to content

Commit

Permalink
fix: Params flash undefined on specific route progression
Browse files Browse the repository at this point in the history
Fixes #889
  • Loading branch information
tannerlinsley committed Dec 28, 2023
1 parent 14e15fa commit 998861c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/react-router/src/Matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function MatchRoute<
return !!params ? props.children : null
}

function getRenderedMatches(state: RouterState) {
export function getRenderedMatches(state: RouterState) {
return state.pendingMatches?.some((d) => d.showPending)
? state.pendingMatches
: state.matches
Expand Down
3 changes: 2 additions & 1 deletion packages/react-router/src/useParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RegisteredRouter } from './router'
import { last } from './utils'
import { useRouterState } from './RouterProvider'
import { StrictOrFrom } from './utils'
import { getRenderedMatches } from './Matches'

export function useParams<
TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],
Expand All @@ -18,7 +19,7 @@ export function useParams<
): TSelected {
return useRouterState({
select: (state: any) => {
const params = (last(state.matches) as any)?.params
const params = (last(getRenderedMatches(state)) as any)?.params
return opts?.select ? opts.select(params) : params
},
})
Expand Down

0 comments on commit 998861c

Please sign in to comment.