![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@woocommerce/block-templates
Advanced tools
Utilities for working with block templates in WooCommerce admin.
A collection of utility functions for use with WooCommerce admin block templates.
Registers a WooCommerce block type.
import { registerWooBlockType } from '@woocommerce/block-templates';
import metadata from './block.json';
import { Edit } from './edit';
registerWooBlockType( {
name: metadata.name,
metadata: metadata,
settings: {
edit: Edit,
},
} );
Object
: Block metadata.WPBlockType | undefined
: The block type if it was registered successfully, otherwise undefined
.This hook is used to retrieve a layout template from the server.
import { useLayoutTemplate } from '@woocommerce/block-templates';
export function Example() {
const { layoutTemplate, isResolving } =
useLayoutTemplate( 'my-layout-template' );
return (
<div>
{ isResolving && <p>Loading layout template...</p> }
{ layoutTemplate && (
<p>{ JSON.stringify( layoutTemplate, null, 4 ) }</p>
) }
{ ! layoutTemplate && ! isResolving && (
<p>'Layout template does not exist!'</p>
) }
</div>
);
}
string
: The id of the layout template to retrieve.Object
Object | undefined
: The layout template if it was found, otherwise null
.boolean
: Whether or not the layout template is resolving.This hook is used to lightly mark an element as a WooCommerce block template block. The block's attributes must be passed to this hook and the return result passed to the outermost element of the block in order for the block to properly function in WooCommerce block template contexts.
If you define a ref for the element, it is important to pass the ref to this hook, which the hook in turn will pass to the component through the props it returns. Optionally, you can also pass any other props through this hook, and they will be merged and returned.
import { useWooBlockProps } from '@woocommerce/block-templates';
export function Edit( { attributes } ) {
const { blockProps } = useWooBlockProps( attributes, {
className: 'my-block',
} );
return <div { ...blockProps }>Block content</div>;
}
Object
: Block attributes.Object
: Optional. Props to pass to the element.Object
: Props to pass to the element to mark as a WooCommerce block.FAQs
Utilities for working with block templates in WooCommerce admin.
We found that @woocommerce/block-templates demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 20 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.