-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Next.js 15 Circular Structure Error When passing domNode
to another server component
#1589
Comments
Can you provide a reproducible example @webplantmedia? Is this happening on the server-side or client-side? Just curious: if you render with |
Happening all on the server side. I read in HTML from an API. I parse the content like so: const html = parse(content, options); My options are defined similar to the code here: const options: HTMLReactParserOptions = {
replace(domNode) {
if (domNode instanceof Element && domNode.attribs) {
if (domNode.name === 'ul') {
return <CustomList node={domNode} />;
}
}
}
} Next 14, no error. Next 15, Circular Structure Error. |
Gotcha I'll try to reproduce this in the example Next.js app in this repository when I have some time today |
I upgraded the example Next.js app to v15 and I wasn't able to reproduce your error: https://github.com/remarkablemark/html-react-parser/tree/master/examples/nextjs Let me know if there's anything I can adjust to reproduce your error |
My suspicion is that it's coming from this line: <CustomList node={domNode} /> Do you call |
Do you get the same error if you do this in the example Next.js app? https://github.com/remarkablemark/html-react-parser/tree/master/examples/nextjs |
Can you fork and create a branch with these changes? @webplantmedia |
https://github.com/webplantmedia/html-react-parser I just pushed a commit with the code. Thanks so much for looking into it! I have based a very big next js project in using this react parser. I'm hoping there is an easy fix to this without having to refactor lots of code. https://github.com/webplantmedia/html-react-parser/tree/master/examples/nextjs |
Thanks! I'll take a look later today @webplantmedia |
Any insight on the nature of this error? Is it some new code procedure introduced in next js 15? If it is permanent, would I need to drop support of this parser if I need to stick with Next JS? Thank you again. I've been stuck on this for two days. |
@webplantmedia this is happening because Next.js tries to render the data as JSON in a There are 3 solutions:
|
Sigh. I really needed to be able to loop inside other components. And keep it as a server component. Do you see this being a permanent move by nextjs 15 on how they handle complex objects? I really appreciate your insight. Thanks so much. |
@webplantmedia I'm not sure, but I think it's worth creating an issue or discussion on Next.js to confirm. For now, I think 3 could resolve the issue for you, but there may be a chance that it breaks your project. |
domNode
to another server component
I did! I'm assuming if I remove circular reference, it would break But I can't even console log domNode if I want to debug in a server component. Two other html parsers I looked into also have circular referencing. Sigh. |
@webplantmedia yes there's a possibility that if you remove circular reference that it would break |
I'm not sure if this is a bug, or some problem with my NextJS environment, but in Next 14, I could pass domNode from within the replace() function to other server components, and keep my react customizations more organized. But after upgrading to Next 15, I'm getting the following error:
Is this a bug?
The text was updated successfully, but these errors were encountered: