Skip to content

Fix Gutenberg plugin render registration#226

Closed
akirk wants to merge 1 commit into
ocean90:masterfrom
akirk:fix-gutenberg-plugin-render
Closed

Fix Gutenberg plugin render registration#226
akirk wants to merge 1 commit into
ocean90:masterfrom
akirk:fix-gutenberg-plugin-render

Conversation

@akirk

@akirk akirk commented Jul 1, 2026

Copy link
Copy Markdown

During the recent Gutenberg release (see this Slack thread) we discovered that the Public Post Preview was missing on the editor in https://make.wordpress.org/core/ which runs the latest Gutenberg version.

I then discovered that since Gutenberg v23.4.0 the composed PreviewToggle component is rejected when it is passed directly as the render value to registerPlugin.

This was introduced in WordPress/gutenberg#78674. Because it changed withSelect from returning a pure(...) wrapped component to returning a memo(...) wrapped component, this error was thrown:

The "render" property must be specified and must be a valid function. <anonymous code>:1:147461
    overrideMethod <anonymous code>:1
    ra index.ts:157
    <anonymous> gutenberg-integration.js:2
    <anonymous> gutenberg-integration.js:2

Because this plugin's PreviewToggle export is composed with withSelect as the outermost higher-order component, it became a React memo object rather than a plain function. Simply wrapping the component in an anonymous function fixes that.

This change maintains compatibility with older WordPress/Gutenberg versions. Because the registered render value is now a plain function, it passes the old typeof render === 'function' validation, and Gutenberg's PluginArea still renders it as a normal component.

@akirk

akirk commented Jul 1, 2026

Copy link
Copy Markdown
Author

We might equally well close this, as I realize that this will be fixed in Gutenberg 23.5.0 (WordPress/gutenberg#79315) during which release, ironically, this issue was discovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants