-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client router cache should still be cleared if server action revalida…
…tes + redirects (#70715) If a server action redirects, we reject the promise eagerly with a redirect error, but that means we skip the handling that clears the client router cache in case the response was revalidated. This keeps the existing handling to seed the prefetch cache & reject the promise but ensures we've had a chance to apply the flight data to the router state. Fixes #70483 Closes NDX-357
- Loading branch information
Showing
6 changed files
with
126 additions
and
51 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
'use server' | ||
|
||
import { redirect } from 'next/navigation' | ||
import { revalidatePath } from 'next/cache' | ||
|
||
type State = { | ||
errors: Record<string, string> | ||
} | ||
|
||
export async function action(previousState: State, formData: FormData) { | ||
const name = formData.get('name') | ||
const revalidate = formData.get('revalidate') | ||
|
||
if (name !== 'justputit') { | ||
return { errors: { name: "Only 'justputit' is accepted." } } | ||
} | ||
|
||
if (revalidate === 'on') { | ||
revalidatePath('/redirect') | ||
} | ||
|
||
redirect('/redirect/other') | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return <div>Other Page</div> | ||
return ( | ||
<div> | ||
Other Page <Link href="/redirect">Back to Redirect Page</Link> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export default function Page() { | ||
return <div>Main Page</div> | ||
return ( | ||
<div id="main-page"> | ||
Main Page <div id="rand">{Math.random()}</div> | ||
</div> | ||
) | ||
} |