-
Notifications
You must be signed in to change notification settings - Fork 27.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent revalidateTag/Path during render (#71093)
Makes `revalidatePath` and `revalidateTag` throw if called during render. Revalidating is a side-effecting operation so it should not be allowed there. x-ref: #70642 (comment)
- Loading branch information
1 parent
1b21c3a
commit fd552c5
Showing
3 changed files
with
57 additions
and
2 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
24 changes: 24 additions & 0 deletions
24
test/e2e/app-dir/revalidatetag-rsc/app/revalidate_via_page/page.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,24 @@ | ||
'use server' | ||
|
||
import Link from 'next/link' | ||
import { revalidateTag } from 'next/cache' | ||
|
||
const RevalidateViaPage = async ({ | ||
searchParams, | ||
}: { | ||
searchParams: Promise<{ tag: string }> | ||
}) => { | ||
const { tag } = await searchParams | ||
revalidateTag(tag) | ||
|
||
return ( | ||
<div className="flex flex-col items-center justify-center h-screen"> | ||
<pre>Tag [{tag}] has been revalidated</pre> | ||
<Link href="/" id="home"> | ||
To Home | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export default RevalidateViaPage |
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