• I have developed a block that should optionally accept inner blocks… for example a <code><figure></code> which should optionally receive a description (<code><figcaption></code>).

    Now, in my research, I found out that the ‘InnerBlocks’ component is outdated and it is better to use the ‘useInnerBlocksProps’ hook. Basically it works quite well, but I just can’t find any documentation or code for it. The few examples are very superficial and very helpful for getting started… but simply inadequate for productive use.

    For example, I would like to determine whether there are already InnerBlocks, since the description should be optional and I only display the entire tag if either a button was pressed in the editor or a description already exists. The hook gives me an object that has a property called ‘children’. Unfortunately, it’s not possible to figure out what that is (a function? an array? an object?). Attempting to log the content fails because there are circular dependencies that JSON.stringify cannot resolve…

    Of course, this property isn’t documented either… so does anyone have an idea how I can determine if InnerBlocks already exist? or where I can find Information about the Hook and its property: children?

  • The topic ‘useInnerBlocksProps Hook instead of InnerBlocks Component’ is closed to new replies.