Insert a custom block into a custom block (without InnerBlocks)
-
Hi everyone!
This is my first message here, so I hope I am at the right place to ask my question!
To give the big picture of what I need to do, I will simplify my problem.
I have created two custom Gutenberg blocks, let’s call them slider and slide. I would like to insert slide in the code returned by theedit
function of slider, and not usingInnerBlocks
with a template.I can’t use InnerBlocks as it adds several
<div>
elements around the child element that breaks the styling.Sample of the
slide
block:registerBlockType('slide-block', { // ... parent: ['slider-block'], edit: () => ( <div className="slide"> Slide content </div> ); // ... });
Sample of the edit function of the
slider
block:edit: () => ( <div className="slider"> // INSERT SLIDE BLOCK HERE </div> );
The slide class has to be a direct child of the slider class for styling reasons, and that is why I can’t use InnerBlocks.
Any help or idea would be greatly appreciated ??
- The topic ‘Insert a custom block into a custom block (without InnerBlocks)’ is closed to new replies.