Things I’m learning while playing with Gutenberg (part I)

I’ve been having fun working heavily with Gutenberg over the last several weeks. As I ran into a couple things, I started tracking them in a draft post so I could work through and publish them later.

Here’s the first set. 🙂

How to access className from a block’s save() function

The classname attribute is available to a block’s edit() function by default, but it is not available to the block’s save() function. I learned from this GitHub issue that registering className as one of the block’s attributes will provide it to the save() function.

registerBlockType( 'my/block', {

	attributes: {
		className: {
			type: 'string',
			default: '',
		},
	},

	edit( props ) {
		// className via props
		const { attributes, className } = props;
		const { customData } = attributes;

		return ( // ... );
	},

	save( { attributes } ) {
		// className via attributes 
		const { className, customData } = attributes;

		return ( // ... );
	},
} );

Be careful importing Lodash modules

If you want to use something from Lodash, like find():

// Import the module like this
import find from 'lodash/find';

// Not like this...
import { find } from 'lodash';

The latter brings in the global _ from Lodash, which overrides the global _ provided by Underscore and causes trouble.

A this.activateMode is not a function error that prevented media blocks from being used led me to this issue, which helped me.

Beware of non-changing arrays

I ran into this a couple different ways recently and I’m still working on understanding it completely, but things like Array().push and Array().pop modify the reference value of an existing array and may not trigger the state change you’re expecting.

let apples = [];
let oranges = apples;

oranges; // []

apples.push( 1 );
oranges; // [ 1 ]

oranges === apples; // true
oranges === apples.concat( 1 ); //false

I picked up on better approaches for this via this issue when a block’s attributes weren’t saving as expected.

Scratch pad thoughts for January 12, 2019

Costa first novel award winner recalls ‘awful’ time writing his book:

He was working as a travel writer in Dubai when the idea that would become Evelyn Hardcastle struck him. “It was the body-hopping and the Groundhog Day loop. I didn’t have anything else, the characters or murder, I just had that concept. The moment I got it, I thought: ‘Oh crap, now I’ve got to go and do that, and I’ve got to be in England, I need that atmosphere, those stately homes. I need to be lost in drizzly forests, I cannot do that in the desert,’” he says. “I was terrified the entire time, from the moment the idea came and I knew I had to follow through on it.”

I love that description of an idea.


Nadia Eghbal thinks through seed stage philanthropy and includes an interesting though on patronage:

“I also keep thinking about the need for something like Patreon, but “Patron”. Basically, a platform that inverts the ask, so it’s not just grantees soliciting money, but patrons who advertise their giving interests, like angel investors on AngelList.”


If Your Privacy Is in the Hands of Others Alone, You Don’t Have Any

It is only by owning [root authority over our lives] that we can crank up agency on the individual’s side. We have a perfect base for that in the standards and protocols that gave us the Internet, the Web, email and too little else. And we need it here too. Soon.

Doc Searls with a super interesting post contrasting privacy regulations with attempts to actually assert privacy rights. I like the idea of Customer Commons, which I hadn’t heard about until now.


‘It’s tough sleeping at night’: ranchers seek to protect herds as wolves move in

I asked Sumner how seeing the wolf made him feel, and it took him some time to elaborate. Earlier in the day, he had lamented how some wolf advocates glorified the species. But when describing his emotions when he saw the wolf three years ago, reverence crept into his tone.


I had no idea how much of an impact wolves had on politics, policy, feelings, and everything else until moving to Eastern Washington. This article on wolves moving into California for the first time since the 1920s was great.

My other appreciation for this article is that it was done in partnership with Pacific Standard, an independent news magazine, which in turn had support from the Society of Environmental Journalists.


I made it years with NPM and just learned that npm ci performs a clean install of a project’s NPM dependencies from the package-lock.json file rather than package.json. This helped me through a confusing situation where npm install was updating the repo’s package-lock.json file for reasons.

Scratch pad thoughts

I’m still trying to figure out a format for “tweet”-like things without titles that I want to publish, but not on Twitter. For now, I’ve kept a draft post going called “Scratch pad” that I decided to use as a base for the week (or whatever).

One of my least favorite things about the new WordPress editor is the attempt to auto-embed any link that’s pasted on a line of its own, even if it doesn’t advertise oEmbed support. It makes it strangely annoying with my normal workflow for tracking links as part of future posts.

I finally decided I can work around things by using a Custom HTML block to start the post. This gives me an unformatted window of text that I can then pick from when needed.

How far we’ve come to get away from a simple textarea. 🙂

When format and publish a scratch pad, I’m going to plan on titling it “Scratch pad thoughts for {date}”. I’ll note this is inspired by Tom Woodward’s “Weekly Web Harvest” posts and the “Four short links” format used by Nat Torkington at O’Reilly and Daniel Bachhuber.

I’m sure there are more examples of these round-up / link posts out there and I’d love to hear of them. They’re the best feed reader reading!