Skip to content

Custom code with data binding not rendering properly server side #3956

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

Open
tristanoneil opened this issue Mar 8, 2025 · 0 comments
Open

Comments

@tristanoneil
Copy link

Describe the bug
We have a Builder page that has an element with an HTML attribute that is bound to a custom code block. This works fine when rendered client side and results in something like data-swiper-options="{"some": "json"} but when it's rendered server side it results in data-swiper-options="[object Object]". This poses a problem because we're mounting BuilderComponent client-side using hydrate and it's not re-rendering the HTML so data-swiper-options="[object Object]" remains.

To Reproduce
Steps to reproduce the behavior:

  1. Create a builder page that includes an element with an HTML attribute that is bound to custom code that looks like:
const options = `{
  "some": "json"
}`

export default options;
  1. Render this page server side using @builder.io/react version 8.0.9 (we're just using Node 20.18.3 with renderToString)
  2. 💥 See that the HTML produced does not properly return executed custom code but instead [object Object] -- presumably a representation of the actual custom code instead of the result of it's execution.

Expected behavior
Custom code should be executed server side resulting in the proper HTML output.

Additional context
I've created a page where this is reproducible in my Builder space here: https://builder.io/content/f8608641b0604e938a2a50965af27017/edit

I've noticed that this does work when the page is rendered using the HTML API, so theoretically this should be supported.

I've noticed that this scenario also seems to break the JSX editor in the Builder editor. It results in the following when you click "Toggle JSX Editor":

Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant