I have a custom Shopify solution and I’m using Builder.io for static content like the home page with Next JS.
I used my custom react components only and I want to have a header and footer for other dynamic pages like product and collection.
I converted the header and footer to a symbol from the home page model content. and I managed to edit the symbol but when I want to render it on the page, I got nothing but when I add a simple text. I got it. the issue is with my custom react component doesn’t render on other pages but it does work on the home page.
Hey Ilias, given that the issue involves custom components, it’s challenging for me to really suggest anything concrete because I don’t have access to the full breadth of the code that might be involved. I understand that you might not be able to share all of your code but if you could produce a code-sandbox that demonstrates at least the core of your issue it’d be a lot easier to help.
I have a template here that you can modify to demonstrate the issue, just swap out the builder API key for your own and make what ever other changes are required to try and render the symbols.
PS: I don’t understand the relevance of EditBuilderSymbol in your example above, it doesn’t looks like it’s referred to in the other example.
I think there may be some confusion about what symbols are used for - custom components largely fill the same role, you would use a symbol if you wanted to create a reusable template that’s managed within builder, where as a custom component would be a reusable template that’s managed in your own codebase.
Okay so as I understand it, you want to have pages that are controlled in code, and would like the render the header and footer within these pages, and have the header and footer be content that’s managed by builder - is that correct?
If that’s the case we have some documentations about this specific use-case here under the section “Section Models”.
For your example, rather than using a single “symbols” model to manage your headers and footers, try creating two separate models, “header”, and “footer” to manage this content.
In your react code you’d include a BuilderComponent for each model sandwiched around your content:
import { builder, BuilderComponent } from "@builder.io/react";
builder.init("YJIGb4i01jvw0SRdL5Bt");
export default function IndexPage() {
return (
<div>
<BuilderComponent model="header" />
Here's some content that's managed in next.js
<BuilderComponent model="footer" />
</div>
);
}
And then just make sure that this file is imported for the side-effect of registering with builder to occur (as explained in that linked documentation).
Your components should then be available in the insert menu if they were registered correctly like in gif here:
If things aren’t working I would check the console for errors and verify that the code where you’re calling Builder.registerComponent is being called.