← 문제 목록
고급
Next.js
100P
Server Action과 revalidate 타이밍
다음 코드에서 버그를 찾으세요:
JAVASCRIPT
// app/actions.js
'use server';
import { revalidateTag } from 'next/cache';
export async function updateProduct(id, data) {
revalidateTag('products');
await db.product.update({ where: { id }, data });
return { success: true };
}
// app/products/page.js
export default async function ProductsPage() {
const products = await fetch('https://api.example.com/products', {
next: { tags: ['products'] }
}).then(res => res.json());
return <ProductList products={products} />;
}
// 업데이트 후 목록에 이전 데이터가 표시됨
0명 풀이 · 정답률 0%