Skip to content

Commit c144d40

Browse files
committed
improve unit tests
1 parent 29ffc5c commit c144d40

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/router-core/src/router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ export type CommitLocationFn = ({
710710
...next
711711
}: ParsedLocation & CommitLocationOptions) => Promise<void>
712712

713-
export type StartTransitionFn = (fn: () => void) => void
713+
export type StartTransitionFn = (fn: () => void | Promise<void>) => void
714714

715715
export interface MatchRoutesFn {
716716
(

packages/solid-router/src/Transitioner.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ export function Transitioner() {
3737

3838
router.startTransition = (fn: () => void | Promise<void>) => {
3939
setIsTransitioning(true)
40-
Solid.startTransition(async () => {
41-
try {
42-
await fn()
43-
} finally {
40+
const result = fn()
41+
if (result instanceof Promise) {
42+
result.finally(() => {
4443
setIsTransitioning(false)
45-
}
46-
})
44+
})
45+
} else {
46+
setIsTransitioning(false)
47+
}
4748
}
4849

4950
// Subscribe to location changes

0 commit comments

Comments
 (0)