Fix Gutenberg plugin render registration#226
Closed
akirk wants to merge 1 commit into
Closed
Conversation
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
PreviewTogglecomponent is rejected when it is passed directly as therendervalue toregisterPlugin.This was introduced in WordPress/gutenberg#78674. Because it changed
withSelectfrom returning apure(...)wrapped component to returning amemo(...)wrapped component, this error was thrown:Because this plugin's
PreviewToggleexport is composed withwithSelectas 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
rendervalue is now a plain function, it passes the oldtypeof render === 'function'validation, and Gutenberg'sPluginAreastill renders it as a normal component.