Jake Paris

WordPress Block Editor Development Cheat Sheet

Module Location Reference

I often can’t remember which of these things lives in which package. Note that there are two ways to import these into your block. Either during the build process which looks like:

import {
    Button,
} from '@wordpress/components';

or at run time using the global wp and destructuring which looks like:

const {
    Button,
} = wp.components;

I used to use the global wp method all the time under the impression that importing all the various component dependencies into my block would bloat the code uneccessarily. However, I did some testing to this end, and really couldn’t find any difference in the size of the compiled script or the speed of anything. I don’t understand that, but there it is.

@wordpress/blocks

  • createBlock
  • rawHandler
  • registerBlockType

@wordpress/components

@wordpress/compose

@wordpress/data

  • dispatch
  • select
  • withSelect

@wordpress/editor

@wordpress/element

  • Component
  • Fragment

@wordpress/server-side-render

Note, if importing from `wp.serverSideRender`, instead of `@wordpress/server-side-render`, you have to rename the import to begin with a capital. So:

import { 
    serverSideRender: ServerSideRender 
} from window.wp.serverSideRender;
  • ServerSideRender