Skip to content

How to use template in useInnerBlocksProps? #121

Answered by fabiankaegy
miho-birds asked this question in Q&A
Discussion options

You must be logged in to vote

Hey 👋

The useInnerBlocksProps hook accepts two objects as its arguments. The first object can contain any attributes you want to add to the wrapping element. The second object contains all of the settings for the inner block area.

So in your example this would look something like this:

const MY_TEMPLATE = [ ...Array(37) ].map( () => [ 'core/list', {} ] );

const innerBlocksProps = useInnerBlocksProps(
    {
        className: 'items',
    },
    {
        template: MY_TEMPLATE,
        templateLock: 'all'
    }
);

<ul {...innerBlocksProps} />

hope this helps :)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@miho-birds
Comment options

Answer selected by fabiankaegy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants