admin管理员组文章数量:1127085
How can I use a custom block inside another custom block?
I have created a custom block(Block A) that works fine.
Now I am creating another custom block(Block B) and want to embed the Block A inside it.
I tried to use the InnerBlocks like this
<InnerBlocks
defaultBlock={[
"Block A"
]}
directInsert
/>
but it doesn't work.
How can I use a custom block inside another custom block?
I have created a custom block(Block A) that works fine.
Now I am creating another custom block(Block B) and want to embed the Block A inside it.
I tried to use the InnerBlocks like this
<InnerBlocks
defaultBlock={[
"Block A"
]}
directInsert
/>
but it doesn't work.
Share Improve this question asked Jan 12, 2024 at 13:57 Muhammad KamalMuhammad Kamal 1114 bronze badges1 Answer
Reset to default 1Finally,I have found a solution. I can pass my custom block to the InnerBlocks inside a template prop.
const TEMPLATE = [
[
"core/columns",
{},
[
[
"core/column",
{},
[["custom/Block A", { url: "this is a url" }]],
],
[
"core/column",
{},
[["core/paragraph", { placeholder: "Enter side content..." }]],
],
],
],
];
<InnerBlocks template={TEMPLATE} />
本文标签: Use a custom block inside another custom block
版权声明:本文标题:Use a custom block inside another custom block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736692778a1948022.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论