• Resolved silvanarnet

    (@silvanarnet)


    Hello everyone

    I’m trying to use the InnerBlocks ButtonBlockAppender inside a custom block, where I use Block- and InnerBlocksProps. But it doesn’t work…

    My question: Is this even possible or is there another way?
    I know I just could use the InnerBlock Component instead of BlockProps but that wouldn’t be as “satisfying”

    I’ve tried like this:

    const {useBlockProps, useInnerBlocksProps, InnerBlocks} = wp.blockEditor;
    
    export default ({setAttributes, clientId}) => {
    	setAttributes({accordionId: clientId});
    	const blockProps = useBlockProps();
    	const innerBlockProps = useInnerBlocksProps(
    		{
    			className: 'accordion',
    		},
    		{
    			allowedBlocks: ['test/accordion-item'],
    		},
    		{
    			template: [['test/accordion-item', {}]],
    		},
    		{
    			renderAppender: InnerBlocks.ButtonBlockAppender,
    		},
    	);
    	return (
    		<>
    			
    </> ); };
Viewing 1 replies (of 1 total)
  • Thread Starter silvanarnet

    (@silvanarnet)

    Found the solution:

        const innerBlockProps = useInnerBlocksProps(
    
            {
    
                className: 'accordion',
    
            },
    
            {
    
                allowedBlocks: ['wk/accordion-item'],
    
                template: [['wk/accordion-item', {}]],
    
                renderAppender: () => (
    
                    <InnerBlocks.ButtonBlockAppender />
    
                ),
    
            },
    
        );
    • This reply was modified 1 year, 11 months ago by silvanarnet.
Viewing 1 replies (of 1 total)
  • The topic ‘Using RenderApender with innerBlocksProps’ is closed to new replies.