-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix use cache example line highlights #71883
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,7 +268,7 @@ A `cacheTag` is used in combination with [`revalidateTag`](/docs/app/api-referen | |
|
||
In the below example the `getData` function uses the “weeks” cache profile, and defines a `cacheTag` on the functions cached output: | ||
|
||
```tsx filename="app/actions.ts" highlight={4,5} | ||
```tsx filename="app/actions.ts" highlight={8,9} | ||
import { | ||
unstable_cacheTag as cacheTag, | ||
unstable_cacheLife as cacheLife, | ||
|
@@ -286,7 +286,7 @@ export async function getData() { | |
|
||
You can then purge the cache on-demand using revalidateTag in another function, for examples, a [route handler](/docs/app/building-your-application/routing/route-handlers) or [Server Action](/docs/app/building-your-application/data-fetching/server-actions-and-mutations): | ||
|
||
```tsx filename="app/submit.ts" highlight={4,5} | ||
```tsx filename="app/submit.ts" highlight={6,7} | ||
'use server' | ||
|
||
import { revalidateTag } from 'next/cache' | ||
|
@@ -311,7 +311,7 @@ This is recommended for applications that previously used the [`export const dyn | |
|
||
```tsx filename="app/layout.tsx" | ||
"use cache" | ||
import { unstable_cacheLife as cacheLife} from 'next/cache' | ||
import { unstable_cacheLife as cacheLife } from 'next/cache' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. driveby style fix |
||
cacheLife('minutes') | ||
|
||
export default Layout({children}: {children: ReactNode}) { | ||
|
@@ -323,7 +323,7 @@ And in your `page.tsx` file you can add the `use cache` directive to the top of | |
|
||
```tsx filename="app/page.tsx" | ||
"use cache" | ||
import { unstable_cacheLife as cacheLife} from 'next/cache' | ||
import { unstable_cacheLife as cacheLife } from 'next/cache' | ||
cacheLife('minutes') | ||
|
||
async function Users() { | ||
|
@@ -346,7 +346,7 @@ You can use `use cache` at the component level to cache any fetches or computati | |
|
||
The props are serialized and form part of the cache key. If you use the same component in multiple places in your application, the cache entry will be reused as long as the serialized props produce the same value in each instance. | ||
|
||
```tsx filename="app/components/bookings.tsx" highlight={4,5} | ||
```tsx filename="app/components/bookings.tsx" highlight={8,9} | ||
import { unstable_cacheLife as cacheLife } from 'next/cache' | ||
|
||
interface BookingsProps { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix