-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add deprecated call to wp.components.ServerSideRender; Remove some missed wp.components.ServerSideRender usages. #16133
Add deprecated call to wp.components.ServerSideRender; Remove some missed wp.components.ServerSideRender usages. #16133
Conversation
79e0058
to
e3b6997
Compare
e3b6997
to
2b74300
Compare
This PR was updated to avoid arrow function usage, it should be ready. |
2b74300
to
988f83a
Compare
lib/client-assets.php
Outdated
' if ( wp && wp.components && wp.serverSideRender && ! wp.components.ServerSideRender ) {', | ||
' wp.components.ServerSideRender = wp.serverSideRender;', | ||
' };', | ||
' if ( wp && wp.components && wp.serverSideRender ) {', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit worried that this might not work in all cases. What if someone has a block which imports ServerSideRender
from wp.components
but never references wp-server-side-render
as a dependency. It's a tough problem. I see that we expose ServerSideRender
from wp.editor
, so maybe we should attach this polyfill there without any guard clauses? Or even we could include it inside @wordpress/editor
which is less likely to be used outside of WordPress.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you still need to rebase this PR after I merged your other PR which updates import for ServerSideRender
.
988f83a
to
1926ec7
Compare
Hi @gziolo the PR was rebased. |
|
||
if( window && window.wp && window.wp.components ) { | ||
window.wp.components.ServerSideRender = forwardRef( ( props, ref ) => { | ||
wp.deprecated( 'wp.components.ServerSideRender', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you import deprecated
to ensure it's listed as a dependency of the module when generating deps file for WordPress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated 👍
if( window && window.wp && window.wp.components ) { | ||
window.wp.components.ServerSideRender = forwardRef( ( props, ref ) => { | ||
wp.deprecated( 'wp.components.ServerSideRender', { | ||
alternative: 'wp.serverSideRender', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit unfortunate that this global variable starts with lowercase.
8af3a96
to
4515584
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with the following change:
@@ -17,10 +17,10 @@ import {
BlockControls,
InspectorControls,
} from '@wordpress/block-editor';
-import ServerSideRender from '@wordpress/server-side-render';
const DEFAULT_MIN_ITEMS = 1;
const DEFAULT_MAX_ITEMS = 10;
+const { ServerSideRender } = wp.components;
class RSSEdit extends Component {
constructor() {
which is the closest you can get when developing as plugin. It works perfectly fine and I can see deprecation message:
I can also see wp.components.ServerSideRender
when using Web Console.
I noticed that PHP and JS linters are still unhappy. You will have to convince them this PR is ready to go :) |
4515584
to
aa092c9
Compare
Description
Follow up from #15635.
In #15635 we kept the back-compatibility for usages of wp.components.ServerSideRender but we did not implement a deprecated call.
This PR adds the missing deprecated call.
How has this been tested?
I changed the archives block to use ServerSideRender from wp.components.
I verified the block works as expected, but a deprecated warning is thrown in the browser console.