-
Notifications
You must be signed in to change notification settings - Fork 27.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when nextjs tries to warn about non-plain object prop binding - Error: Cannot convert a Symbol value to a string #61966
Comments
Hi, The problem here is that you have to consider that, there's a network boundary when you do: export default function Home() {
return (
<main>
{/* other stuff */}
<Thing href={new URL("https://example.com")}>WARN, BUT RENDERS</Thing>
<Thing as={SomeLink} href={new URL("https://example.com")}>
ERROR, BREAKS PAGE TRYING TO LOG WARNING?
</Thing>
{/* other stuff */}
</main>
);
} Precisely here: Not everything can be serialized, and deserialized for that matter. In this case, serialize means to be able to transform this data structure into another data structure that can be sent over HTTP from the server to the client, and which the client can then transform back to the original data structure. The transformation can be no transformation at all. The React Server Components lists a bunch of things that they can support as serializable data: Notably URL is not listed, and it is not supported as serializable, however possible it might look like. I guess the However, this line is important:
In your example, you are passing a Client Component to the And functions are not supported (unless Server Actions): However you could do: <Thing
as={<SomeLink href="http://example.com" />}
href={new URL('https://example.com')}
>
ERROR, BREAKS PAGE TRYING TO LOG WARNING?
</Thing> Notice that I am passing Then you'd just need to update your type in the Thing |
Completely agree, the code we have doesn't work and shouldn't. The issue is that the code in next.js that tries to render the warning causes the page to error out instead of a warning to be shown on the next console/output. I think I tracked this down and it may be upstream in react. ReactFlightWebReference.js L216-227 Notice how all the other references to name have it wrapped in a String(name) call except the last one. I think it's just missing the String() call to ensure it can stringify name which is possibly/in-this-case a Symbol? |
But the error is because you are passing a function, the A function can't be serialized. You have to change it to a React Element, JSX, rather than a React Component, a function. |
The Will be fixed by facebook/react#28355 |
Link to the code that reproduces this issue
https://github.com/jon-ressio/vercel-prop-warn-error
To Reproduce
Note: This only happens when running under
next dev
,next build && next start
works as expectedCurrent vs. Expected behavior
From page.tsx,
<Thing>
is included twice. The first instance causesWarning: Only plain objects can be passed to Client Components from Server Components. URL objects are not supported.
to show up in the server console, but the second instance causes the page to error out with:TypeError: Cannot convert a Symbol value to a string
The
as={SomeLink}
prop seems to not be handled by the Next/react warning, so the code trying to generate/show the warning causes a runtime error.Expected: To render the same warning for the second
<Thing>
as done for the first.Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Issue does not exist in 13.5.6, does exist in 14.0.0
The text was updated successfully, but these errors were encountered: