-
-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(react-router): properly handle redirects when thrown during paral…
- Loading branch information
1 parent
0718fb8
commit 224a261
Showing
6 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
e2e/react-router/basic-file-based/src/routes/redirect/preload/first.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Link, createFileRoute } from '@tanstack/react-router' | ||
|
||
export const Route = createFileRoute('/redirect/preload/first')({ | ||
component: RouteComponent, | ||
}) | ||
|
||
function RouteComponent() { | ||
return ( | ||
<div data-testid="first"> | ||
<Link | ||
from={Route.fullPath} | ||
to="../second" | ||
activeProps={{ | ||
className: 'font-bold', | ||
}} | ||
preload="intent" | ||
data-testid={'link'} | ||
> | ||
go to second | ||
</Link> | ||
</div> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
e2e/react-router/basic-file-based/src/routes/redirect/preload/second.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createFileRoute, redirect } from '@tanstack/react-router' | ||
|
||
export const Route = createFileRoute('/redirect/preload/second')({ | ||
loader: async () => { | ||
await new Promise((r) => setTimeout(r, 1000)) | ||
throw redirect({ from: Route.fullPath, to: '../third' }) | ||
}, | ||
component: RouteComponent, | ||
pendingComponent: () => <p>second pending</p>, | ||
}) | ||
|
||
function RouteComponent() { | ||
return <div data-testid="second">Hello "/redirect/preload/second"!</div> | ||
} |
9 changes: 9 additions & 0 deletions
9
e2e/react-router/basic-file-based/src/routes/redirect/preload/third.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createFileRoute } from '@tanstack/react-router' | ||
|
||
export const Route = createFileRoute('/redirect/preload/third')({ | ||
component: RouteComponent, | ||
}) | ||
|
||
function RouteComponent() { | ||
return <div data-testid="third">Hello "/redirect/preload/third"!</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters