We were rendering children as in the example of HeroWithChildren:
The issue with above, is that the children are not passed builderState.context, it is empty. To replicate the issue, try out this simplified custom component:
It works great, until you nest a custom component that needs access to builderState.context. Then, the props.builderState.context.callbackFn() is undefined and throws an error in the child CustomComponent. The outer still works.
Maybe not the right place to post this, but wanted to share my findings. This would be a good piece to clarify in docs. Perhaps you could document the actual code in Github, as that would provide a good overview of expected props and usage builder/builder-blocks.component.tsx at main · BuilderIO/builder · GitHub
ah yes, props.builderBlock.children is the raw JSON representation
if you use withChildren() we will map the JSON to actual React component children that can render directly with {props.children} (vs the JSON would instead need to be {props.builderBlock.children.map(child => <BuilderBlock block={child} />)})
So it’s just for convenience, if you don’t use withChildren we won’t add props.children
The main benefit is with withChildren you get better reuse, like