Skip to content

Commit 32e6158

Browse files
committed
fix onEnter test
1 parent 7eb3a1d commit 32e6158

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

packages/router-core/src/router.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,18 +2131,19 @@ export class RouterCore<
21312131
})
21322132
this.clearExpiredCache()
21332133
})
2134-
})
21352134

2136-
//
2137-
;(
2138-
[
2139-
[exitingMatches, 'onLeave'],
2140-
[enteringMatches, 'onEnter'],
2141-
[stayingMatches, 'onStay'],
2142-
] as const
2143-
).forEach(([matches, hook]) => {
2144-
matches.forEach((match) => {
2145-
this.looseRoutesById[match.routeId]!.options[hook]?.(match)
2135+
// Call lifecycle hooks inside the transition so they execute synchronously
2136+
// even when startTransition is async (e.g., in Solid)
2137+
;(
2138+
[
2139+
[exitingMatches, 'onLeave'],
2140+
[enteringMatches, 'onEnter'],
2141+
[stayingMatches, 'onStay'],
2142+
] as const
2143+
).forEach(([matches, hook]) => {
2144+
matches.forEach((match) => {
2145+
this.looseRoutesById[match.routeId]!.options[hook]?.(match)
2146+
})
21462147
})
21472148
})
21482149
})

0 commit comments

Comments
 (0)