JavaScript for WordPress Forums Gutenberg Development Working with deprecated block features/updating in the wild Reply To: Working with deprecated block features/updating in the wild

#59818
Zac Gordon
Keymaster

Hi Phil!

Great question 🙂 I will be adding a short video on this in my next update (when GB get’s closer to an alpha release in Core).

This tutorial may help a bit too: https://atomicblocks.com/how-to-deprecate-gutenberg-editor-blocks/

The problem this solves is if you make a non-dynamic block and change anything in the save setting it will break the block. This is a huuuuge problem. So, the solution the Core team came up with is to provide old versions of your block that it can reference if anything changes. This prevents it from breaking.

It is a bit of a PITA and clunky I agree. However, one way to make it a bit nicer is to create a “versions” folder and save old versions in there as versions/block-name.X.X.js and then import and include reference to them in the deprecated setting. This will keep your code a little cleaner (like how we did with some of the icons and inspector settings in a few block examples).

Another approach is to make all your blocks dynamic and avoid this problem, but then you’re writing everything in PHP and JS and there is still a chance at some point you may make a change that breaks things.

Hope that helps explains things a bit?

Let me know if you hit any snags implementing or have any other high level questions about this 🙂

So glad you’re enjoying the course!

Cheers,
Zac