Skip to content

Commit

Permalink
Update rsc error message (#41351)
Browse files Browse the repository at this point in the history
Follow up for #41333, updating the error message with `"use client"` directives in suggestion
  • Loading branch information
huozhi committed Oct 12, 2022
1 parent bf630e8 commit 8db5991
Showing 1 changed file with 6 additions and 6 deletions.
Expand Up @@ -19,24 +19,24 @@ export function formatRSCErrorMessage(
if (NEXT_RSC_ERR_REACT_API.test(message)) {
formattedMessage = message.replace(
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 =
'\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)) {
formattedMessage = message.replace(
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 =
'\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)) {
formattedMessage = message.replace(
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 =
'\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]
Expand Down

0 comments on commit 8db5991

Please sign in to comment.