Last active
June 2, 2023 15:21
-
-
Save phpbits/2514fdb6dacabcb51200d8ab2b46a0db to your computer and use it in GitHub Desktop.
Access InnerBlocks in the Edit Component: https://jeffreycarandang.com/how-to-access-innerblocks-attributes-within-the-parent-block-on-the-wordpress-gutenberg-editor/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { __ } = wp.i18n; | |
const { useSelect } = wp.data; | |
const { store: blockEditorStore } = wp.blockEditor; | |
/** | |
* Block Edit Component | |
*/ | |
const Edit = (props) => { | |
const { clientId } = props; | |
const innerBlocks = useSelect( | |
(select) => select(blockEditorStore).getBlock(clientId).innerBlocks, | |
); | |
console.log( innerBlocks ); // This will log all the inner blocks on your browser console | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment