How to use the @wordpress/data.useRegistry function in @wordpress/data

To help you get started, we’ve selected a few @wordpress/data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / packages / composite-checkout / src / lib / registry.js View on Github external
export function useRegisterStore( id, store ) {
	const { registerStore } = useRegistry();
	useConstructor( () => registerStore( id, store ) );
}
github pristas-peter / wp-graphql-gutenberg / src / PostTypes / block-editor-preview / index.js View on Github external
return ( props ) => {
			const { setBlocks } = useDispatch( `wp-graphql-gutenberg/block-editor-preview` );

			const registry = useRegistry();
			const blocks = registry.select( `core/block-editor` ).getBlocks();
			const coreBlock = useContext( CoreBlockContext );

			const id = useSelect( ( select ) => select( `core/editor` ).getCurrentPostId(), [] );

			const coreBlockId =
				( coreBlock && coreBlock.attributes.ref && parseInt( coreBlock.attributes.ref, 10 ) ) || null;

			useEffect( () => {
				if ( id ) {
					setBlocks( {
						id,
						blocks,
						coreBlockId,
					} );
				}