Skip to content

Commit 94ea50f

Browse files
authored
refactor(react-router,solid-router): Minor simplification of MatchInner match logic in select (#4921)
We don't need the `matchIndex` in `Match > MatchInner > useRouterState > select`. It must have been left after a previous refactor.
1 parent b84a5ce commit 94ea50f

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/react-router/src/Match.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ export const MatchInner = React.memo(function MatchInnerImpl({
189189

190190
const { match, key, routeId } = useRouterState({
191191
select: (s) => {
192-
const matchIndex = s.matches.findIndex((d) => d.id === matchId)
193-
const match = s.matches[matchIndex]!
192+
const match = s.matches.find((d) => d.id === matchId)!
194193
const routeId = match.routeId as string
195194

196195
const remountFn =

packages/solid-router/src/Match.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ export const MatchInner = (props: { matchId: string }): any => {
185185

186186
const matchState = useRouterState({
187187
select: (s) => {
188-
const matchIndex = s.matches.findIndex((d) => d.id === props.matchId)
189-
const match = s.matches[matchIndex]!
188+
const match = s.matches.find((d) => d.id === props.matchId)!
190189
const routeId = match.routeId as string
191190

192191
const remountFn =

0 commit comments

Comments
 (0)