Unverified Commit 3c3710be authored by Jam Balaya's avatar Jam Balaya Committed by GitHub

chore: update `getting-started/react-essentials` path (#72250)

## Description
At #51579, react-essentials.mdx was deleted.
Some URLs doesn't navigate right pages due to this change.
Then I update to correct path.

- Fixes https://github.com/vercel/next.js/issues/72566

---------
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent ebc36781
...@@ -249,10 +249,10 @@ fn report_error(app_dir: &Option<PathBuf>, filepath: &str, error_kind: RSCErrorK ...@@ -249,10 +249,10 @@ fn report_error(app_dir: &Option<PathBuf>, filepath: &str, error_kind: RSCErrorK
RSCErrorKind::NextRscErrServerImport((source, span)) => { RSCErrorKind::NextRscErrServerImport((source, span)) => {
let msg = match source.as_str() { let msg = match source.as_str() {
// If importing "react-dom/server", we should show a different error. // If importing "react-dom/server", we should show a different error.
"react-dom/server" => "You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials".to_string(), "react-dom/server" => "You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering".to_string(),
// If importing "next/router", we should tell them to use "next/navigation". // If importing "next/router", we should tell them to use "next/navigation".
"next/router" => r#"You have a Server Component that imports next/router. Use next/navigation instead.\nLearn more: https://nextjs.org/docs/app/api-reference/functions/use-router"#.to_string(), "next/router" => r#"You have a Server Component that imports next/router. Use next/navigation instead.\nLearn more: https://nextjs.org/docs/app/api-reference/functions/use-router"#.to_string(),
_ => format!(r#"You're importing a component that imports {source}. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n"#) _ => format!(r#"You're importing a component that imports {source}. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\n\n"#)
}; };
(msg, span) (msg, span)
...@@ -270,29 +270,29 @@ fn report_error(app_dir: &Option<PathBuf>, filepath: &str, error_kind: RSCErrorK ...@@ -270,29 +270,29 @@ fn report_error(app_dir: &Option<PathBuf>, filepath: &str, error_kind: RSCErrorK
.unwrap_or_default(); .unwrap_or_default();
let msg = if !is_app_dir { let msg = if !is_app_dir {
format!("You're importing a component that needs \"{source}\". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components\n\n") format!("You're importing a component that needs \"{source}\". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components\n\n")
} else { } else {
format!("You're importing a component that needs \"{source}\". That only works in a Server Component but one of its parents is marked with \"use client\", so it's a Client Component.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n") format!("You're importing a component that needs \"{source}\". That only works in a Server Component but one of its parents is marked with \"use client\", so it's a Client Component.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\n\n")
}; };
(msg, span) (msg, span)
} }
RSCErrorKind::NextRscErrReactApi((source, span)) => { RSCErrorKind::NextRscErrReactApi((source, span)) => {
let msg = if source == "Component" { let msg = if source == "Component" {
"You’re importing a class component. It only works in a Client Component but none of its parents are marked with \"use client\", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n".to_string() "You’re importing a class component. It only works in a Client Component but none of its parents are marked with \"use client\", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n".to_string()
} else { } else {
format!("You're importing a component that needs `{source}`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `\"use client\"` directive.\n\n Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n") format!("You're importing a component that needs `{source}`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `\"use client\"` directive.\n\n Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n")
}; };
(msg,span) (msg,span)
}, },
RSCErrorKind::NextRscErrErrorFileServerComponent(span) => { RSCErrorKind::NextRscErrErrorFileServerComponent(span) => {
( (
format!("{filepath} must be a Client Component. Add the \"use client\" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n"), format!("{filepath} must be a Client Component. Add the \"use client\" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n"),
span span
) )
}, },
RSCErrorKind::NextRscErrClientMetadataExport((source, span)) => { RSCErrorKind::NextRscErrClientMetadataExport((source, span)) => {
(format!("You are attempting to export \"{source}\" from a component marked with \"use client\", which is disallowed. Either remove the export, or the \"use client\" directive. Read more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n"), span) (format!("You are attempting to export \"{source}\" from a component marked with \"use client\", which is disallowed. Either remove the export, or the \"use client\" directive. Read more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n"), span)
}, },
RSCErrorKind::NextRscErrConflictMetadataExport(span) => ( RSCErrorKind::NextRscErrConflictMetadataExport(span) => (
"\"metadata\" and \"generateMetadata\" cannot be exported at the same time, please keep one of them. Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata\n\n".to_string(), "\"metadata\" and \"generateMetadata\" cannot be exported at the same time, please keep one of them. Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata\n\n".to_string(),
......
x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/ x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
| react-essentials#server-components | application/rendering/server-components
| |
| |
,-[input.js:9:1] ,-[input.js:9:1]
......
x You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn x You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn
| more: https://nextjs.org/docs/getting-started/react-essentials\n\n | more: https://nextjs.org/docs/app/building-your-application/rendering\n\n
,-[input.js:9:1] ,-[input.js:9:1]
8 | 8 |
9 | import 'client-only' 9 | import 'client-only'
......
x You're importing a component that needs `useState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:1:1] ,-[input.js:1:1]
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
`---- `----
x You're importing a component that needs `createContext`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `createContext`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:3:1] ,-[input.js:3:1]
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
`---- `----
x You're importing a component that needs `useEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:5:1] ,-[input.js:5:1]
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
`---- `----
x You're importing a component that needs `useImperativeHandle`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useImperativeHandle`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:5:1] ,-[input.js:5:1]
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
: ^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^
`---- `----
x You’re importing a class component. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default. x You’re importing a class component. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
| Learn more: https://nextjs.org/docs/getting-started/react-essentials#client-components | Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components
| |
| |
,-[input.js:8:1] ,-[input.js:8:1]
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
`---- `----
x You're importing a component that needs `createFactory`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `createFactory`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:9:1] ,-[input.js:9:1]
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
`---- `----
x You're importing a component that needs `PureComponent`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `PureComponent`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:10:1] ,-[input.js:10:1]
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
`---- `----
x You're importing a component that needs `useDeferredValue`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useDeferredValue`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:11:1] ,-[input.js:11:1]
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
`---- `----
x You're importing a component that needs `useInsertionEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useInsertionEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:12:1] ,-[input.js:12:1]
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
`---- `----
x You're importing a component that needs `useLayoutEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useLayoutEffect`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:13:1] ,-[input.js:13:1]
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
`---- `----
x You're importing a component that needs `useReducer`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useReducer`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:14:1] ,-[input.js:14:1]
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
`---- `----
x You're importing a component that needs `useRef`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useRef`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:15:1] ,-[input.js:15:1]
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
`---- `----
x You're importing a component that needs `useSyncExternalStore`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useSyncExternalStore`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:16:1] ,-[input.js:16:1]
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
`---- `----
x You're importing a component that needs `experimental_useOptimistic`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `experimental_useOptimistic`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:19:1] ,-[input.js:19:1]
......
x You're importing a component that needs `flushSync`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `flushSync`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:1:1] ,-[input.js:1:1]
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
`---- `----
x You're importing a component that needs `unstable_batchedUpdates`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `unstable_batchedUpdates`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:1:1] ,-[input.js:1:1]
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
`---- `----
x You're importing a component that needs `useActionState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useActionState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:3:1] ,-[input.js:3:1]
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
`---- `----
x You're importing a component that needs `useFormStatus`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useFormStatus`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:5:1] ,-[input.js:5:1]
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
`---- `----
x You're importing a component that needs `useFormState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive. x You're importing a component that needs `useFormState`. This React hook only works in a client component. To fix, mark the file (or its parent) with the `"use client"` directive.
| |
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
| |
| |
,-[input.js:5:1] ,-[input.js:5:1]
......
x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/getting-started/react-essentials | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[input.js:9:1] ,-[input.js:9:1]
8 | 8 |
9 | import 'react-dom/server' 9 | import 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^
`---- `----
x You're importing a component that imports react-dom/client. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default. x You're importing a component that imports react-dom/client. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
| \nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n | \nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\n\n
,-[input.js:11:1] ,-[input.js:11:1]
10 | 10 |
11 | import 'react-dom/client' 11 | import 'react-dom/client'
......
...@@ -30,11 +30,11 @@ function formatRSCErrorMessage( ...@@ -30,11 +30,11 @@ function formatRSCErrorMessage(
if (NEXT_RSC_ERR_REACT_API.test(message)) { if (NEXT_RSC_ERR_REACT_API.test(message)) {
const matches = message.match(NEXT_RSC_ERR_REACT_API) const matches = message.match(NEXT_RSC_ERR_REACT_API)
if (matches && matches[1] === 'Component') { if (matches && matches[1] === 'Component') {
formattedMessage = `\n\nYou’re importing a class component. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n` formattedMessage = `\n\nYou’re importing a class component. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n`
} else { } else {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_REACT_API, NEXT_RSC_ERR_REACT_API,
`\n\nYou're importing a component that needs $1. This React hook only works in a client component. To fix, mark the file (or its parent) with the \`"use client"\` directive. \n\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering/client-components\n\n` `\n\nYou're importing a component that needs $1. This React hook only works in a client component. To fix, mark the file (or its parent) with the \`"use client"\` directive. \n\nLearn more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n`
) )
} }
formattedVerboseMessage = formattedVerboseMessage =
...@@ -45,7 +45,7 @@ function formatRSCErrorMessage( ...@@ -45,7 +45,7 @@ function formatRSCErrorMessage(
switch (matches && matches[1]) { switch (matches && matches[1]) {
case 'react-dom/server': case 'react-dom/server':
// If importing "react-dom/server", we should show a different error. // If importing "react-dom/server", we should show a different error.
formattedMessage = `\n\nYou're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials` formattedMessage = `\n\nYou're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering`
break break
case 'next/router': case 'next/router':
// If importing "next/router", we should tell them to use "next/navigation". // If importing "next/router", we should tell them to use "next/navigation".
...@@ -55,7 +55,7 @@ function formatRSCErrorMessage( ...@@ -55,7 +55,7 @@ function formatRSCErrorMessage(
default: default:
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_SERVER_IMPORT, NEXT_RSC_ERR_SERVER_IMPORT,
`\n\nYou're importing a component that imports $1. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n` `\n\nYou're importing a component that imports $1. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\n\n`
) )
} }
formattedVerboseMessage = shouldAddUseClient formattedVerboseMessage = shouldAddUseClient
...@@ -65,13 +65,13 @@ function formatRSCErrorMessage( ...@@ -65,13 +65,13 @@ function formatRSCErrorMessage(
if (isPagesDir) { if (isPagesDir) {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_CLIENT_IMPORT, NEXT_RSC_ERR_CLIENT_IMPORT,
`\n\nYou're importing a component that needs $1. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components\n\n` `\n\nYou're importing a component that needs $1. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components\n\n`
) )
formattedVerboseMessage = '\n\nImport trace for requested module:\n' formattedVerboseMessage = '\n\nImport trace for requested module:\n'
} else { } else {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_CLIENT_IMPORT, NEXT_RSC_ERR_CLIENT_IMPORT,
`\n\nYou're importing a component that needs $1. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\n\n` `\n\nYou're importing a component that needs $1. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\n\n`
) )
formattedVerboseMessage = formattedVerboseMessage =
'\n\nOne of these is marked as a client entry with "use client":\n' '\n\nOne of these is marked as a client entry with "use client":\n'
...@@ -85,7 +85,7 @@ function formatRSCErrorMessage( ...@@ -85,7 +85,7 @@ function formatRSCErrorMessage(
} else if (NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN.test(message)) { } else if (NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN.test(message)) {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN, NEXT_RSC_ERR_CLIENT_DIRECTIVE_PAREN,
`\n\n"use client" must be a directive, and placed before other expressions. Remove the parentheses and move it to the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n` `\n\n"use client" must be a directive, and placed before other expressions. Remove the parentheses and move it to the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n`
) )
formattedVerboseMessage = '\n\nImport path:\n' formattedVerboseMessage = '\n\nImport path:\n'
} else if (NEXT_RSC_ERR_INVALID_API.test(message)) { } else if (NEXT_RSC_ERR_INVALID_API.test(message)) {
...@@ -97,13 +97,13 @@ function formatRSCErrorMessage( ...@@ -97,13 +97,13 @@ function formatRSCErrorMessage(
} else if (NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT.test(message)) { } else if (NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT.test(message)) {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT, NEXT_RSC_ERR_ERROR_FILE_SERVER_COMPONENT,
`\n\n${fileName} must be a Client Component. Add the "use client" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/getting-started/react-essentials#client-components\n\n` `\n\n${fileName} must be a Client Component. Add the "use client" directive the top of the file to resolve this issue.\nLearn more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n`
) )
formattedVerboseMessage = '\n\nImport path:\n' formattedVerboseMessage = '\n\nImport path:\n'
} else if (NEXT_RSC_ERR_CLIENT_METADATA_EXPORT.test(message)) { } else if (NEXT_RSC_ERR_CLIENT_METADATA_EXPORT.test(message)) {
formattedMessage = message.replace( formattedMessage = message.replace(
NEXT_RSC_ERR_CLIENT_METADATA_EXPORT, NEXT_RSC_ERR_CLIENT_METADATA_EXPORT,
`\n\nYou are attempting to export "$1" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://nextjs.org/docs/getting-started/react-essentials#the-use-client-directive\n\n` `\n\nYou are attempting to export "$1" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https://nextjs.org/docs/app/api-reference/directives/use-client\n\n`
) )
formattedVerboseMessage = '\n\nFile path:\n' formattedVerboseMessage = '\n\nFile path:\n'
......
...@@ -196,7 +196,7 @@ describe('Error overlay - RSC build errors', () => { ...@@ -196,7 +196,7 @@ describe('Error overlay - RSC build errors', () => {
3 | export default function ClientOnlyLib() { 3 | export default function ClientOnlyLib() {
4 | return 'client-only-lib' 4 | return 'client-only-lib'
You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\\nLearn more: https://nextjs.org/docs/getting-started/react-essentials\\n\\n" You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.\\nLearn more: https://nextjs.org/docs/app/building-your-application/rendering\\n\\n"
`) `)
} else { } else {
expect(await session.getRedboxSource()).toInclude( expect(await session.getRedboxSource()).toInclude(
...@@ -342,7 +342,7 @@ describe('Error overlay - RSC build errors', () => { ...@@ -342,7 +342,7 @@ describe('Error overlay - RSC build errors', () => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/server-with-errors/error-file/error.js must be a Client Component. Add the "use client" directive the top of the file to resolve this issue. app/server-with-errors/error-file/error.js must be a Client Component. Add the "use client" directive the top of the file to resolve this issue.
Learn more: https://nextjs.org/docs/getting-started/react-essentials#client-components" Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client"
`) `)
} else { } else {
await check(() => session.getRedboxSource(), /Add the "use client"/) await check(() => session.getRedboxSource(), /Add the "use client"/)
...@@ -353,7 +353,7 @@ describe('Error overlay - RSC build errors', () => { ...@@ -353,7 +353,7 @@ describe('Error overlay - RSC build errors', () => {
// "./app/server-with-errors/error-file/error.js // "./app/server-with-errors/error-file/error.js
// Error: x TEST_DIR/app/server-with-errors/error-file/error.js must be a Client // Error: x TEST_DIR/app/server-with-errors/error-file/error.js must be a Client
// | Component. Add the "use client" directive the top of the file to resolve this issue. // | Component. Add the "use client" directive the top of the file to resolve this issue.
// | Learn more: https://nextjs.org/docs/getting-started/react-essentials#client-components // | Learn more: https://nextjs.org/docs/app/api-reference/directives/use-client
// | // |
// | // |
// ,---- // ,----
......
...@@ -61,14 +61,14 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -61,14 +61,14 @@ describe('Error Overlay for server components compiler errors in pages', () => {
3 | export default function Page() { 3 | export default function Page() {
4 | return <p>hello world</p> 4 | return <p>hello world</p>
You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components" You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else { } else {
expect(next.normalizeTestDirContent(await session.getRedboxSource())) expect(next.normalizeTestDirContent(await session.getRedboxSource()))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/ Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
| react-essentials#server-components | your-application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
...@@ -119,7 +119,7 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -119,7 +119,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
3 | export default function Page() { 3 | export default function Page() {
4 | return 'hello world' 4 | return 'hello world'
You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components" You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else { } else {
expect( expect(
...@@ -129,8 +129,8 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -129,8 +129,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
) )
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/ Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
| react-essentials#server-components | application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
...@@ -178,7 +178,7 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -178,7 +178,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
3 | export default function Page() { 3 | export default function Page() {
4 | return 'hello world' 4 | return 'hello world'
You're importing a component that needs "unstable_after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/react-essentials#server-components" You're importing a component that needs "unstable_after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
`) `)
} else { } else {
expect( expect(
...@@ -188,8 +188,8 @@ describe('Error Overlay for server components compiler errors in pages', () => { ...@@ -188,8 +188,8 @@ describe('Error Overlay for server components compiler errors in pages', () => {
) )
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"./components/Comp.js "./components/Comp.js
Error: x You're importing a component that needs "unstable_after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting- Error: x You're importing a component that needs "unstable_after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
| started/react-essentials#server-components | your-application/rendering/server-components
| |
| |
,-[1:1] ,-[1:1]
......
...@@ -294,7 +294,7 @@ describe('react-dom/server in React Server environment', () => { ...@@ -294,7 +294,7 @@ describe('react-dom/server in React Server environment', () => {
6 | 6 |
You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Learn more: https://nextjs.org/docs/getting-started/react-essentials", Learn more: https://nextjs.org/docs/app/building-your-application/rendering",
} }
`) `)
} else { } else {
...@@ -389,7 +389,7 @@ describe('react-dom/server in React Server environment', () => { ...@@ -389,7 +389,7 @@ describe('react-dom/server in React Server environment', () => {
6 | 6 |
You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Learn more: https://nextjs.org/docs/getting-started/react-essentials", Learn more: https://nextjs.org/docs/app/building-your-application/rendering",
} }
`) `)
} else { } else {
...@@ -398,7 +398,7 @@ describe('react-dom/server in React Server environment', () => { ...@@ -398,7 +398,7 @@ describe('react-dom/server in React Server environment', () => {
"description": "Failed to compile", "description": "Failed to compile",
"source": "./app/exports/app-code/react-dom-server-node-implicit/page.js "source": "./app/exports/app-code/react-dom-server-node-implicit/page.js
Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/getting-started/react-essentials | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[1:1] ,-[1:1]
1 | import * as ReactDOMServerNode from 'react-dom/server' 1 | import * as ReactDOMServerNode from 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...@@ -406,7 +406,7 @@ describe('react-dom/server in React Server environment', () => { ...@@ -406,7 +406,7 @@ describe('react-dom/server in React Server environment', () => {
3 | import ReactDOMServerNodeDefault from 'react-dom/server' 3 | import ReactDOMServerNodeDefault from 'react-dom/server'
\`---- \`----
x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security. x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/getting-started/react-essentials | Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[3:1] ,-[3:1]
1 | import * as ReactDOMServerNode from 'react-dom/server' 1 | import * as ReactDOMServerNode from 'react-dom/server'
2 | // Fine to drop once React is on ESM 2 | // Fine to drop once React is on ESM
......
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