-
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
Is withAPIData being deprecated? #7390
Comments
Yes, correct. We are planning to deprecate it soon. It's not marked as deprecated yet, because we still use it in a few places, but it's something we want to replace with gutenberg/core-blocks/categories/edit.js Lines 210 to 217 in c2a5189
gutenberg/packages/core-data/src/resolvers.js Lines 26 to 29 in 5851831
In addition, we offer a selector which verifies if the request is in progress: gutenberg/packages/core-data/src/selectors.js Lines 74 to 76 in 4d3e3f6
Related docs: |
It might be a good idea to update the handbook section dedicated to building dynamic blocks cause it still makes reference to https://wordpress.org/gutenberg/handbook/blocks/creating-dynamic-blocks/ |
Good catch, I opened #7397. Thanks! |
I don't know if this is the right place to comment but I'm experiencing a malfunction of the code with |
Hi there, I also don't know if this is the correct place to comment, but following the new guidance I cannot get My issue is that the 'controls' section of the recomended Even after all that, I'm not sure if I am going down the right path. For some more examples of my specific issue, I've wrote about my problem on stackexchange here: https://wordpress.stackexchange.com/questions/311431/in-gutenberg-now-that-withapidata-is-being-deprecated-how-can-i-do-an-async-ca if its of any help. |
@IacopoC I've now answered my own question, it may help you too: https://wordpress.stackexchange.com/a/311551/148566 Here is my solution:
By doing this you can access this via withSelect like so:
|
@mwtsn Thank you |
@mattwatsoncodes @gziolo The latest dev version is returning the error below : Uncaught (in promise) Error: Actions must be plain objects. Use custom middleware for async actions. Hoping you can point me out on the best solution. Thanks! |
For those stumbling on this in search be aware that this pull has examples that will no longer work because of api changes in the wp.data package. More up-to-date examples and current documentation can be found here: https://github.com/WordPress/gutenberg/tree/master/packages/data |
@phpbits I had the problem with the "Uncaught (in promise) Error: Actions must be plain objects." warning and found a solution to that. It seems that the resolver methods no longer retrieve the So in the example on this page, this code
need to be changed to this:
Plus: If you're using an old example, please note that you no need a control method in your store. The page that I've linked says that "This can be particularly useful in implementing asynchronous data flows" Hope this helps you as well. |
Thanks @phpbits @nerrad @code-flow the updated code for my solution is as follows:
|
I've seen some mentions here about
withAPIData
being deprecated in the near future. I'm using this component in a couple of blocks I'm developing and I don't know which is the alternative method to get dynamic data. I see that the Latest Posts block is still using it, so I don't know how to proceed.Would someone point me to the right direction, please?
Thanks
The text was updated successfully, but these errors were encountered: