-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Update ServerSideRender dependencies in the dynamic blocks documentation #12344
Comments
It is most likely related to #12057 |
Hi, I also have a similar issue, but I'm using es6. Previously i need to replace But I get an error on the console log that saying the API endpoint for my custom block not registered (error 404). It's related to #12057. Then I notice there's something wrong on the API endpoint. I get something like this Anyone, please help. Thx |
Your script is missing the wp-components dependency. That‘s why Your workaround only works because it loads all sorts of dependencies, including wp-components. The rule of thumb is: if you want to access |
Thanks, but the key is that the code is copy and paste from an official handbook. |
https://wordpress.org/gutenberg/handbook/blocks/creating-dynamic-blocks/ doesn‘t show how to register/enqueue the JS, so which page do you feel should be improved? |
Exactly the one you quoted that starts with “The following code example shows how to create the latest post block dynamic block.” |
Oops! That page can’t be found |
@Otshelnik-Fm https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/tutorials/block-tutorial/creating-dynamic-blocks.md The block tutorial got mistakenly removed from the handbook on WordPress.org so there's the direct link. Working on getting it back :) |
As @swissspidy mentioned, you need to include the 'wp-components' dependency:
Make sure to include the 'wp-components' when registering your block.js file. This fixed the issue, but the documentation page does need updating. |
Since PR 8720 ServerSideRender comes from wp.editor not wp.components. Docs need updating. |
ServerSideRender had been moved to its own package since the last time this issue was commented on; the dynamic blocks documentation regarding this was updated in #19012 |
There seems to be some issue with documentation and recent update. It works in v.4.4.0 but not since 4.5.0
Here's proof of concept. It either needs documentation improvement or it's a bug.
Following: https://wordpress.org/gutenberg/handbook/blocks/creating-dynamic-blocks/ you should be able to create a simple block.
index.php
latest-post/block.js
This worked in 4.4 but now produces block.js?ver=4.9.8:5 Uncaught TypeError: Cannot read property 'ServerSideRender' of undefined
There's something missing in documentation what's changed between versions.
A quick workaround, which is silly, is to attach the empty JS file dependent on block. This fixes the problem if added on the very bottom of index.php file
The text was updated successfully, but these errors were encountered: