Skip to content

Instantly share code, notes, and snippets.

@dennyf
dennyf / simplify-gutengerg.js
Last active March 23, 2018 12:45
This is an example of how we can simplify Gutenberg's custom block API - this is only an illustrative example
const { __ } = wp.i18n; // Import __() from wp.i18n
const { registerBlockType, RichText, UrlInput, InspectorControls, PanelColor, ColorPalette } = wp.blocks;
/**
* This class registers a custom block type, by creating the
* controls and updating the values automatically. It also allows passing a single
* render function to avoid repetitive code in edit and update.
*/
class MyCustomComponent{