From a3243e6710284621a7379162f28f0807e7e274af Mon Sep 17 00:00:00 2001 From: Aleksandr Kondrashov <116561995+aramikuto@users.noreply.github.com> Date: Sat, 27 Jan 2024 07:05:04 +0900 Subject: [PATCH] Refine revalidatePath warning message (#61220) #61159 fixed the documentation by removing incorrect information stating that the type parameter must be set to 'page' when the path contains a dynamic segment. This PR reflects this change in the warning message, while confirming that the condition for the warning is already correct. Additionally, I changed the word "affect" to "effect," assuming it was a typo. In the documentation, I corrected myself and changed the wording from "argument is required" to "parameter is required". --- docs/02-app/02-api-reference/04-functions/revalidatePath.mdx | 2 +- packages/next/src/server/web/spec-extension/revalidate.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/02-app/02-api-reference/04-functions/revalidatePath.mdx b/docs/02-app/02-api-reference/04-functions/revalidatePath.mdx index d2bc21308abdd..534e64383adf0 100644 --- a/docs/02-app/02-api-reference/04-functions/revalidatePath.mdx +++ b/docs/02-app/02-api-reference/04-functions/revalidatePath.mdx @@ -19,7 +19,7 @@ revalidatePath(path: string, type?: 'page' | 'layout'): void; ``` - `path`: Either a string representing the filesystem path associated with the data you want to revalidate (for example, `/product/[slug]/page`), or the literal route segment (for example, `/product/123`). Must be less than 1024 characters. -- `type`: (optional) `'page'` or `'layout'` string to change the type of path to revalidate. If `path` contains a dynamic segment (for example, `/product/[slug]/page`), this argument is required. +- `type`: (optional) `'page'` or `'layout'` string to change the type of path to revalidate. If `path` contains a dynamic segment (for example, `/product/[slug]/page`), this parameter is required. ## Returns diff --git a/packages/next/src/server/web/spec-extension/revalidate.ts b/packages/next/src/server/web/spec-extension/revalidate.ts index edc9621638e06..163cbb633590e 100644 --- a/packages/next/src/server/web/spec-extension/revalidate.ts +++ b/packages/next/src/server/web/spec-extension/revalidate.ts @@ -27,7 +27,7 @@ export function revalidatePath(originalPath: string, type?: 'layout' | 'page') { normalizedPath += `${normalizedPath.endsWith('/') ? '' : '/'}${type}` } else if (isDynamicRoute(originalPath)) { console.warn( - `Warning: a dynamic page path "${originalPath}" was passed to "revalidatePath" without the "page" argument. This has no affect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath` + `Warning: a dynamic page path "${originalPath}" was passed to "revalidatePath", but the "type" parameter is missing. This has no effect by default, see more info here https://nextjs.org/docs/app/api-reference/functions/revalidatePath` ) } return revalidate(normalizedPath, `revalidatePath ${originalPath}`)