Skip to content

Instantly share code, notes, and snippets.

@ravewebdev
Last active July 15, 2020 20:48
Show Gist options
  • Save ravewebdev/d2a3f732974bf7e73a9862ddfa456558 to your computer and use it in GitHub Desktop.
Save ravewebdev/d2a3f732974bf7e73a9862ddfa456558 to your computer and use it in GitHub Desktop.
1.1. Unique Block Identifiers
registerBlockType( 'rave/initiative-tracker', {
title: __( 'Initiative Tracker', 'initiative-tracker' ),
attributes: {
id: {
type: 'string',
default: '',
},
},
edit: ( props ) => {
const {
attributes: {
id,
},
clientId,
setAttributes,
} = props;
useEffect( () => {
if ( 0 === id.length ) {
setAttributes( {
id: clientId,
} );
}
}, [] );
},
save: () => null,
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment