Skip to content

Commit

Permalink
docs(cacheTag): remove unused cacheLife import and add missing `swi…
Browse files Browse the repository at this point in the history
…tcher` (#72217)

This PR fixes two issues on the
[cacheTag](https://nextjs.org/docs/canary/app/api-reference/functions/cacheTag)
documentation page:

1. Remove the unused `unstable_cacheLife` import in the TypeScript
codeblock of [Creating tags from external
data](https://nextjs.org/docs/canary/app/api-reference/functions/cacheTag#creating-tags-from-external-data)
section:


![image](https://github.com/user-attachments/assets/db401635-f07b-4e48-bd39-9a21adedce41)


2. Missing `switcher` for TS codeblock in [Creating tags from external
data](https://nextjs.org/docs/canary/app/api-reference/functions/cacheTag#creating-tags-from-external-data)
and [Invalidating tagged
cache](https://nextjs.org/docs/canary/app/api-reference/functions/cacheTag#invalidating-tagged-cache)
sections. We already have the corresponding JS codeblock in the
Markdown.


![image](https://github.com/user-attachments/assets/33a36ac4-d936-47dd-8e96-df9e67366680)


![image](https://github.com/user-attachments/assets/2f91f7de-f440-439c-9cce-1749e9645516)

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
  • Loading branch information
Juneezee authored Nov 3, 2024
1 parent 13fafe6 commit 0c14b38
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions docs/02-app/02-api-reference/04-functions/cacheTag.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ export async function Bookings({ type = 'haircut' }) {

You can use the data returned from an async function to tag the cache entry.

```tsx filename="app/components/bookings.tsx"
import {
unstable_cacheTag as cacheTag,
unstable_cacheLife as cacheLife,
} from 'next/cache'
```tsx filename="app/components/bookings.tsx" switcher
import { unstable_cacheTag as cacheTag } from 'next/cache'

interface BookingsProps {
type: string
Expand Down Expand Up @@ -182,7 +179,7 @@ export async function Bookings({ type = 'haircut' }) {

Using [`revalidateTag`](/docs/app/api-reference/functions/revalidateTag), you can invalidate the cache for a specific tag when needed:

```tsx filename="app/actions.ts"
```tsx filename="app/actions.ts" switcher
'use server'

import { revalidateTag } from 'next/cache'
Expand Down

0 comments on commit 0c14b38

Please sign in to comment.