Update directives

parent 42f5931d
......@@ -2,7 +2,7 @@ import { cookies } from 'next/headers'
import React from 'react'
async function getData() {
'use cache'
'use cache: remote'
return fetch('https://next-data-api-endpoint.vercel.app/api/random', {
headers: {
......
async function getCached({ p }) {
'use cache'
'use cache: remote'
const array = await p
if (array instanceof Uint8Array) {
return array[0].toString(16) + '-' + Math.random()
......
import React from 'react'
async function getData() {
'use cache'
'use cache: remote'
return fetch('https://next-data-api-endpoint.vercel.app/api/random', {
next: { revalidate: 0 },
......
import { setTimeout } from 'timers/promises'
export async function getCachedData() {
'use cache'
'use cache: remote'
await setTimeout(1000)
return new Date().toISOString()
}
......@@ -4,7 +4,7 @@ import { getCachedData } from './cached-data'
export async function generateMetadata(): Promise<Metadata> {
// TODO: Deduping with nested caches requires #78703.
// 'use cache'
// 'use cache: remote'
await connection()
......
import { Foo } from '../client'
async function getCachedRandom(x: number, children: React.ReactNode) {
'use cache'
'use cache: remote'
return {
x,
y: Math.random(),
......
......@@ -4,7 +4,7 @@ import Link from 'next/link'
import { connection } from 'next/server'
async function getCachedValue() {
'use cache'
'use cache: remote'
cacheTag('revalidate-and-redirect')
return Math.random()
......
......@@ -9,7 +9,7 @@ async function fetchCachedValue() {
}
async function getCachedValue() {
'use cache'
'use cache: remote'
unstable_cacheTag('revalidate-and-use')
return Math.random()
}
......
import { unstable_cacheLife } from 'next/cache'
async function getCachedRandom(n: number) {
'use cache'
'use cache: remote'
unstable_cacheLife('weeks')
return String(Math.ceil(Math.random() * n))
}
......
import { unstable_cacheTag } from 'next/cache'
async function getCachedRandom() {
'use cache'
'use cache: remote'
unstable_cacheTag('api')
return Math.random()
......
import React from 'react'
async function getData() {
'use cache'
'use cache: remote'
return fetch(
'https://next-data-api-endpoint.vercel.app/api/random?no-store',
......
import React from 'react'
async function getData() {
'use cache'
'use cache: remote'
return fetch('https://next-data-api-endpoint.vercel.app/api/random').then(
(res) => res.text()
......
import { unstable_cacheLife as cacheLife } from 'next/cache'
async function getCachedRandom() {
'use cache'
'use cache: remote'
cacheLife('frequent')
return Math.random()
}
......
......@@ -9,7 +9,7 @@ async function getCachedWithTag({
tag: string
fetchCache?: 'force' | 'revalidate'
}) {
'use cache'
'use cache: remote'
cacheTag(tag, 'c')
// If `force-cache` or `revalidate` is used for the fetch call, it creates
......
......@@ -5,7 +5,7 @@ async function getCachedValue(
iterable: Iterable<number>,
fn: () => string
): Promise<[string, () => string]> {
'use cache'
'use cache: remote'
// Make sure we're always receiving the arguments the same way, regardless of
// whether draft mode is enabled or not. We're asserting that by checking
......@@ -27,13 +27,13 @@ export default async function Page({
}: {
params: Promise<{ mode: string }>
}) {
'use cache'
'use cache: remote'
const { mode } = await params
const offset = 1000
const cachedClosure = async () => {
'use cache'
'use cache: remote'
return new Date(Date.now() + offset).toISOString()
}
......
......@@ -6,7 +6,7 @@ async function refresh() {
}
export default async function Page() {
'use cache'
'use cache: remote'
cacheTag('home')
return (
......
'use cache'
'use cache: remote'
function getRandomValue() {
const v = Math.random()
......
async function Bar() {
'use cache'
'use cache: remote'
const date = new Date().toLocaleTimeString()
console.log('deep inside', date)
return <p>{date}</p>
}
async function Foo() {
'use cache'
'use cache: remote'
console.log('inside')
return <Bar />
}
......
export function createCached(n: number) {
return {
async getRandomValue() {
'use cache'
'use cache: remote'
const v = n + Math.random()
console.log(v)
return v
......
import { revalidatePath, unstable_cache } from 'next/cache'
async function inner() {
'use cache'
'use cache: remote'
return Math.random()
}
......
'use cache'
'use cache: remote'
import { notFound } from 'next/navigation'
......
......@@ -2,7 +2,7 @@ import { revalidatePath } from 'next/cache'
import { RevalidateButtons } from './revalidate-buttons'
async function cachedValue() {
'use cache'
'use cache: remote'
return Math.random()
}
......
......@@ -11,15 +11,15 @@ export default function Page() {
return (
<Form
foo={async function fooNamed() {
'use cache'
'use cache: remote'
return offset + getRandomValue()
}}
bar={async function () {
'use cache'
'use cache: remote'
return offset + getRandomValue()
}}
baz={async () => {
'use cache'
'use cache: remote'
return offset + getRandomValue()
}}
/>
......
......@@ -2,17 +2,17 @@ import { connection } from 'next/server'
import { Suspense } from 'react'
async function outermost(id: string) {
'use cache'
'use cache: remote'
return id + middle('middle')
}
async function middle(id: string) {
'use cache'
'use cache: remote'
return id + innermost('inner')
}
async function innermost(id: string) {
'use cache'
'use cache: remote'
return id
}
......
......@@ -10,7 +10,7 @@ function Component() {
}
async function getCachedComponent() {
'use cache'
'use cache: remote'
return (
<div>
<p id="a">{number()}</p>
......
/* eslint-disable no-self-compare */
async function getObject(arg: unknown) {
'use cache'
'use cache: remote'
return { arg }
}
async function getObjectWithBoundArgs(arg: unknown) {
async function getCachedObject() {
'use cache'
'use cache: remote'
return { arg }
}
......
import { ClientComponent } from './client'
async function getLargeObject() {
'use cache'
'use cache: remote'
return { hello: 'world' }
}
......
export class Cached {
static async getRandomValue() {
'use cache'
'use cache: remote'
const v = Math.random()
console.log(v)
return v
......
'use cache'
'use cache: remote'
export async function getRandomValue() {
const v = Math.random()
......
......@@ -7,7 +7,7 @@ async function action() {
}
export default async function Page() {
'use cache'
'use cache: remote'
return (
<Form action={action}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment