Unverified Commit 8db59917 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Update rsc error message (#41351)

Follow up for #41333, updating the error message with `"use client"` directives in suggestion
parent bf630e8e
...@@ -19,24 +19,24 @@ export function formatRSCErrorMessage( ...@@ -19,24 +19,24 @@ export function formatRSCErrorMessage(
if (NEXT_RSC_ERR_REACT_API.test(message)) { if (NEXT_RSC_ERR_REACT_API.test(message)) {
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. It only works in a Client Component but none of its parents are marked with "client", so they're Server Components by default.\n\n` `\n\nYou're importing a component that needs $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.\n\n`
) )
formattedVerboseMessage = formattedVerboseMessage =
'\n\nMaybe one of these should be marked as a "client" entry:\n' '\n\nMaybe one of these should be marked as a client entry with "use client":\n'
} else if (NEXT_RSC_ERR_SERVER_IMPORT.test(message)) { } else if (NEXT_RSC_ERR_SERVER_IMPORT.test(message)) {
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 "client", so they're Server Components by default.\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.\n\n`
) )
formattedVerboseMessage = formattedVerboseMessage =
'\n\nMaybe one of these should be marked as a "client" entry:\n' '\n\nMaybe one of these should be marked as a client entry "use client":\n'
} else if (NEXT_RSC_ERR_CLIENT_IMPORT.test(message)) { } else if (NEXT_RSC_ERR_CLIENT_IMPORT.test(message)) {
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 "client", so it's a Client Component.\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.\n\n`
) )
formattedVerboseMessage = formattedVerboseMessage =
'\n\nOne of these is marked as a "client" entry:\n' '\n\nOne of these is marked as a client entry with "use client":\n'
} }
return [formattedMessage, formattedVerboseMessage] return [formattedMessage, formattedVerboseMessage]
......
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